diff --git a/packages/google-cloud-tpu/google/cloud/tpu/gapic_version.py b/packages/google-cloud-tpu/google/cloud/tpu/gapic_version.py index 68899264edad..558c8aab67c5 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu/gapic_version.py +++ b/packages/google-cloud-tpu/google/cloud/tpu/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.19.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v1/gapic_version.py b/packages/google-cloud-tpu/google/cloud/tpu_v1/gapic_version.py index 68899264edad..558c8aab67c5 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v1/gapic_version.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.19.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/async_client.py b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/async_client.py index f42787b20d66..ca6a215bb069 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/async_client.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/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, TpuTransport from .transports.grpc_asyncio import TpuGrpcAsyncIOTransport +try: + from google.api_core import client_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 TpuAsyncClient: """Manages TPU nodes and other resources @@ -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.tpu_v1.TpuAsyncClient`.", + extra={ + "serviceName": "google.cloud.tpu.v1.Tpu", + "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.tpu.v1.Tpu", + "credentialsType": None, + }, + ) + async def list_nodes( self, request: Optional[Union[cloud_tpu.ListNodesRequest, dict]] = None, @@ -266,7 +298,7 @@ async def list_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.ListNodesAsyncPager: r"""Lists nodes. @@ -309,8 +341,10 @@ async def sample_list_nodes(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tpu_v1.services.tpu.pagers.ListNodesAsyncPager: @@ -385,7 +419,7 @@ async def get_node( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.Node: r"""Gets the details of a node. @@ -426,8 +460,10 @@ async def sample_get_node(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tpu_v1.types.Node: @@ -486,7 +522,7 @@ async def create_node( node_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 node. @@ -547,8 +583,10 @@ async def sample_create_node(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -623,7 +661,7 @@ async def delete_node( name: Optional[str] = None, retry: OptionalRetry = gapic_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 node. @@ -669,8 +707,10 @@ async def sample_delete_node(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -740,7 +780,7 @@ async def reimage_node( *, retry: OptionalRetry = gapic_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"""Reimages a node's OS. @@ -780,8 +820,10 @@ async def sample_reimage_node(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -837,7 +879,7 @@ async def stop_node( *, retry: OptionalRetry = gapic_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"""Stops a node, this operation is only available with single TPU nodes. @@ -878,8 +920,10 @@ async def sample_stop_node(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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 +979,7 @@ async def start_node( *, retry: OptionalRetry = gapic_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"""Starts a node. @@ -975,8 +1019,10 @@ async def sample_start_node(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1033,7 +1079,7 @@ async def list_tensor_flow_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.ListTensorFlowVersionsAsyncPager: r"""List TensorFlow versions supported by this API. @@ -1076,8 +1122,10 @@ async def sample_list_tensor_flow_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.tpu_v1.services.tpu.pagers.ListTensorFlowVersionsAsyncPager: @@ -1152,7 +1200,7 @@ async def get_tensor_flow_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]]] = (), ) -> cloud_tpu.TensorFlowVersion: r"""Gets TensorFlow Version. @@ -1194,8 +1242,10 @@ async def sample_get_tensor_flow_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.tpu_v1.types.TensorFlowVersion: @@ -1256,7 +1306,7 @@ async def list_accelerator_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.ListAcceleratorTypesAsyncPager: r"""Lists accelerator types supported by this API. @@ -1299,8 +1349,10 @@ async def sample_list_accelerator_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.tpu_v1.services.tpu.pagers.ListAcceleratorTypesAsyncPager: @@ -1375,7 +1427,7 @@ async def get_accelerator_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]]] = (), ) -> cloud_tpu.AcceleratorType: r"""Gets AcceleratorType. @@ -1417,8 +1469,10 @@ async def sample_get_accelerator_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.tpu_v1.types.AcceleratorType: @@ -1478,7 +1532,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. @@ -1489,8 +1543,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. @@ -1531,7 +1587,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. @@ -1542,8 +1598,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. @@ -1584,7 +1642,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. @@ -1600,8 +1658,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 """ @@ -1638,7 +1698,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. @@ -1653,8 +1713,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 """ @@ -1691,7 +1753,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. @@ -1702,8 +1764,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. @@ -1744,7 +1808,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. @@ -1755,8 +1819,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-tpu/google/cloud/tpu_v1/services/tpu/client.py b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/client.py index 8bf1b851b3bb..95e06b1d5f5a 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/client.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/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 @@ -627,6 +637,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( @@ -687,6 +701,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.tpu_v1.TpuClient`.", + extra={ + "serviceName": "google.cloud.tpu.v1.Tpu", + "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.tpu.v1.Tpu", + "credentialsType": None, + }, + ) + def list_nodes( self, request: Optional[Union[cloud_tpu.ListNodesRequest, dict]] = None, @@ -694,7 +731,7 @@ def list_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.ListNodesPager: r"""Lists nodes. @@ -737,8 +774,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.tpu_v1.services.tpu.pagers.ListNodesPager: @@ -810,7 +849,7 @@ def get_node( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.Node: r"""Gets the details of a node. @@ -851,8 +890,10 @@ def sample_get_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tpu_v1.types.Node: @@ -910,7 +951,7 @@ def create_node( node_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 node. @@ -971,8 +1012,10 @@ def sample_create_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1044,7 +1087,7 @@ def delete_node( name: Optional[str] = None, retry: OptionalRetry = gapic_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 node. @@ -1090,8 +1133,10 @@ def sample_delete_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1158,7 +1203,7 @@ def reimage_node( *, retry: OptionalRetry = gapic_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"""Reimages a node's OS. @@ -1198,8 +1243,10 @@ def sample_reimage_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1253,7 +1300,7 @@ def stop_node( *, retry: OptionalRetry = gapic_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"""Stops a node, this operation is only available with single TPU nodes. @@ -1294,8 +1341,10 @@ def sample_stop_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1349,7 +1398,7 @@ def start_node( *, retry: OptionalRetry = gapic_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"""Starts a node. @@ -1389,8 +1438,10 @@ def sample_start_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1445,7 +1496,7 @@ def list_tensor_flow_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.ListTensorFlowVersionsPager: r"""List TensorFlow versions supported by this API. @@ -1488,8 +1539,10 @@ def sample_list_tensor_flow_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.tpu_v1.services.tpu.pagers.ListTensorFlowVersionsPager: @@ -1563,7 +1616,7 @@ def get_tensor_flow_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]]] = (), ) -> cloud_tpu.TensorFlowVersion: r"""Gets TensorFlow Version. @@ -1605,8 +1658,10 @@ def sample_get_tensor_flow_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.tpu_v1.types.TensorFlowVersion: @@ -1664,7 +1719,7 @@ def list_accelerator_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.ListAcceleratorTypesPager: r"""Lists accelerator types supported by this API. @@ -1707,8 +1762,10 @@ def sample_list_accelerator_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.tpu_v1.services.tpu.pagers.ListAcceleratorTypesPager: @@ -1780,7 +1837,7 @@ def get_accelerator_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]]] = (), ) -> cloud_tpu.AcceleratorType: r"""Gets AcceleratorType. @@ -1822,8 +1879,10 @@ def sample_get_accelerator_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.tpu_v1.types.AcceleratorType: @@ -1893,7 +1952,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. @@ -1904,8 +1963,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. @@ -1946,7 +2007,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. @@ -1957,8 +2018,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. @@ -1999,7 +2062,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. @@ -2015,8 +2078,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 """ @@ -2053,7 +2118,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. @@ -2068,8 +2133,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 """ @@ -2106,7 +2173,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. @@ -2117,8 +2184,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. @@ -2159,7 +2228,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. @@ -2170,8 +2239,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-tpu/google/cloud/tpu_v1/services/tpu/pagers.py b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/pagers.py index 5e1edf534b06..9f25db672583 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/pagers.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/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 = cloud_tpu.ListNodesRequest(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 = cloud_tpu.ListNodesRequest(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 = cloud_tpu.ListTensorFlowVersionsRequest(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 = cloud_tpu.ListTensorFlowVersionsRequest(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 = cloud_tpu.ListAcceleratorTypesRequest(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 = cloud_tpu.ListAcceleratorTypesRequest(request) diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/transports/grpc.py b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/transports/grpc.py index a48eb87a4628..03c0452af25d 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/transports/grpc.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/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.tpu_v1.types import cloud_tpu from .base import DEFAULT_CLIENT_INFO, TpuTransport +try: + from google.api_core import client_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.tpu.v1.Tpu", + "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.tpu.v1.Tpu", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TpuGrpcTransport(TpuTransport): """gRPC backend transport for Tpu. @@ -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 @@ -272,7 +360,7 @@ def list_nodes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_nodes" not in self._stubs: - self._stubs["list_nodes"] = self.grpc_channel.unary_unary( + self._stubs["list_nodes"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/ListNodes", request_serializer=cloud_tpu.ListNodesRequest.serialize, response_deserializer=cloud_tpu.ListNodesResponse.deserialize, @@ -296,7 +384,7 @@ def get_node(self) -> Callable[[cloud_tpu.GetNodeRequest], cloud_tpu.Node]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_node" not in self._stubs: - self._stubs["get_node"] = self.grpc_channel.unary_unary( + self._stubs["get_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/GetNode", request_serializer=cloud_tpu.GetNodeRequest.serialize, response_deserializer=cloud_tpu.Node.deserialize, @@ -322,7 +410,7 @@ def create_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_node" not in self._stubs: - self._stubs["create_node"] = self.grpc_channel.unary_unary( + self._stubs["create_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/CreateNode", request_serializer=cloud_tpu.CreateNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -348,7 +436,7 @@ def delete_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_node" not in self._stubs: - self._stubs["delete_node"] = self.grpc_channel.unary_unary( + self._stubs["delete_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/DeleteNode", request_serializer=cloud_tpu.DeleteNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -374,7 +462,7 @@ def reimage_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reimage_node" not in self._stubs: - self._stubs["reimage_node"] = self.grpc_channel.unary_unary( + self._stubs["reimage_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/ReimageNode", request_serializer=cloud_tpu.ReimageNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -401,7 +489,7 @@ def stop_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_node" not in self._stubs: - self._stubs["stop_node"] = self.grpc_channel.unary_unary( + self._stubs["stop_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/StopNode", request_serializer=cloud_tpu.StopNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -427,7 +515,7 @@ def start_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_node" not in self._stubs: - self._stubs["start_node"] = self.grpc_channel.unary_unary( + self._stubs["start_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/StartNode", request_serializer=cloud_tpu.StartNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -456,7 +544,7 @@ def list_tensor_flow_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tensor_flow_versions" not in self._stubs: - self._stubs["list_tensor_flow_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_tensor_flow_versions"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/ListTensorFlowVersions", request_serializer=cloud_tpu.ListTensorFlowVersionsRequest.serialize, response_deserializer=cloud_tpu.ListTensorFlowVersionsResponse.deserialize, @@ -482,7 +570,7 @@ def get_tensor_flow_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_tensor_flow_version" not in self._stubs: - self._stubs["get_tensor_flow_version"] = self.grpc_channel.unary_unary( + self._stubs["get_tensor_flow_version"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/GetTensorFlowVersion", request_serializer=cloud_tpu.GetTensorFlowVersionRequest.serialize, response_deserializer=cloud_tpu.TensorFlowVersion.deserialize, @@ -510,7 +598,7 @@ def list_accelerator_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_accelerator_types" not in self._stubs: - self._stubs["list_accelerator_types"] = self.grpc_channel.unary_unary( + self._stubs["list_accelerator_types"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/ListAcceleratorTypes", request_serializer=cloud_tpu.ListAcceleratorTypesRequest.serialize, response_deserializer=cloud_tpu.ListAcceleratorTypesResponse.deserialize, @@ -536,7 +624,7 @@ def get_accelerator_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_accelerator_type" not in self._stubs: - self._stubs["get_accelerator_type"] = self.grpc_channel.unary_unary( + self._stubs["get_accelerator_type"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/GetAcceleratorType", request_serializer=cloud_tpu.GetAcceleratorTypeRequest.serialize, response_deserializer=cloud_tpu.AcceleratorType.deserialize, @@ -544,7 +632,7 @@ def get_accelerator_type( return self._stubs["get_accelerator_type"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -556,7 +644,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, @@ -573,7 +661,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, @@ -590,7 +678,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, @@ -609,7 +697,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, @@ -628,7 +716,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, @@ -645,7 +733,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-tpu/google/cloud/tpu_v1/services/tpu/transports/grpc_asyncio.py b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/transports/grpc_asyncio.py index 1437d0ebc801..17f4b939c3b1 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/transports/grpc_asyncio.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/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.tpu_v1.types import cloud_tpu from .base import DEFAULT_CLIENT_INFO, TpuTransport from .grpc import TpuGrpcTransport +try: + from google.api_core import client_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.tpu.v1.Tpu", + "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.tpu.v1.Tpu", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TpuGrpcAsyncIOTransport(TpuTransport): """gRPC AsyncIO backend transport for Tpu. @@ -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. @@ -282,7 +367,7 @@ def list_nodes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_nodes" not in self._stubs: - self._stubs["list_nodes"] = self.grpc_channel.unary_unary( + self._stubs["list_nodes"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/ListNodes", request_serializer=cloud_tpu.ListNodesRequest.serialize, response_deserializer=cloud_tpu.ListNodesResponse.deserialize, @@ -308,7 +393,7 @@ def get_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_node" not in self._stubs: - self._stubs["get_node"] = self.grpc_channel.unary_unary( + self._stubs["get_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/GetNode", request_serializer=cloud_tpu.GetNodeRequest.serialize, response_deserializer=cloud_tpu.Node.deserialize, @@ -334,7 +419,7 @@ def create_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_node" not in self._stubs: - self._stubs["create_node"] = self.grpc_channel.unary_unary( + self._stubs["create_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/CreateNode", request_serializer=cloud_tpu.CreateNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -360,7 +445,7 @@ def delete_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_node" not in self._stubs: - self._stubs["delete_node"] = self.grpc_channel.unary_unary( + self._stubs["delete_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/DeleteNode", request_serializer=cloud_tpu.DeleteNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -386,7 +471,7 @@ def reimage_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reimage_node" not in self._stubs: - self._stubs["reimage_node"] = self.grpc_channel.unary_unary( + self._stubs["reimage_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/ReimageNode", request_serializer=cloud_tpu.ReimageNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -413,7 +498,7 @@ def stop_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_node" not in self._stubs: - self._stubs["stop_node"] = self.grpc_channel.unary_unary( + self._stubs["stop_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/StopNode", request_serializer=cloud_tpu.StopNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -439,7 +524,7 @@ def start_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_node" not in self._stubs: - self._stubs["start_node"] = self.grpc_channel.unary_unary( + self._stubs["start_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/StartNode", request_serializer=cloud_tpu.StartNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -468,7 +553,7 @@ def list_tensor_flow_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tensor_flow_versions" not in self._stubs: - self._stubs["list_tensor_flow_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_tensor_flow_versions"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/ListTensorFlowVersions", request_serializer=cloud_tpu.ListTensorFlowVersionsRequest.serialize, response_deserializer=cloud_tpu.ListTensorFlowVersionsResponse.deserialize, @@ -496,7 +581,7 @@ def get_tensor_flow_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_tensor_flow_version" not in self._stubs: - self._stubs["get_tensor_flow_version"] = self.grpc_channel.unary_unary( + self._stubs["get_tensor_flow_version"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/GetTensorFlowVersion", request_serializer=cloud_tpu.GetTensorFlowVersionRequest.serialize, response_deserializer=cloud_tpu.TensorFlowVersion.deserialize, @@ -525,7 +610,7 @@ def list_accelerator_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_accelerator_types" not in self._stubs: - self._stubs["list_accelerator_types"] = self.grpc_channel.unary_unary( + self._stubs["list_accelerator_types"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/ListAcceleratorTypes", request_serializer=cloud_tpu.ListAcceleratorTypesRequest.serialize, response_deserializer=cloud_tpu.ListAcceleratorTypesResponse.deserialize, @@ -553,7 +638,7 @@ def get_accelerator_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_accelerator_type" not in self._stubs: - self._stubs["get_accelerator_type"] = self.grpc_channel.unary_unary( + self._stubs["get_accelerator_type"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/GetAcceleratorType", request_serializer=cloud_tpu.GetAcceleratorTypeRequest.serialize, response_deserializer=cloud_tpu.AcceleratorType.deserialize, @@ -656,7 +741,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: @@ -672,7 +757,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, @@ -689,7 +774,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, @@ -706,7 +791,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, @@ -725,7 +810,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, @@ -744,7 +829,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, @@ -761,7 +846,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-tpu/google/cloud/tpu_v2/gapic_version.py b/packages/google-cloud-tpu/google/cloud/tpu_v2/gapic_version.py index 68899264edad..558c8aab67c5 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2/gapic_version.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.19.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/async_client.py b/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/async_client.py index e2fa90a9e7ce..fc86217c4265 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/async_client.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/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, TpuTransport from .transports.grpc_asyncio import TpuGrpcAsyncIOTransport +try: + from google.api_core import client_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 TpuAsyncClient: """Manages TPU nodes and other resources @@ -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.tpu_v2.TpuAsyncClient`.", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "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.tpu.v2.Tpu", + "credentialsType": None, + }, + ) + async def list_nodes( self, request: Optional[Union[cloud_tpu.ListNodesRequest, dict]] = None, @@ -266,7 +298,7 @@ async def list_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.ListNodesAsyncPager: r"""Lists nodes. @@ -309,8 +341,10 @@ async def sample_list_nodes(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tpu_v2.services.tpu.pagers.ListNodesAsyncPager: @@ -385,7 +419,7 @@ async def get_node( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.Node: r"""Gets the details of a node. @@ -426,8 +460,10 @@ async def sample_get_node(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tpu_v2.types.Node: @@ -486,7 +522,7 @@ async def create_node( node_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 node. @@ -546,8 +582,10 @@ async def sample_create_node(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -622,7 +660,7 @@ async def delete_node( name: Optional[str] = None, retry: OptionalRetry = gapic_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 node. @@ -668,8 +706,10 @@ async def sample_delete_node(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -747,7 +787,7 @@ async def stop_node( *, retry: OptionalRetry = gapic_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"""Stops a node. This operation is only available with single TPU nodes. @@ -789,8 +829,10 @@ async def sample_stop_node(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -846,7 +888,7 @@ async def start_node( *, retry: OptionalRetry = gapic_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"""Starts a node. @@ -887,8 +929,10 @@ async def sample_start_node(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -946,7 +990,7 @@ async def update_node( 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 configurations of a node. @@ -1005,8 +1049,10 @@ async def sample_update_node(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1080,7 +1126,7 @@ async def generate_service_identity( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.GenerateServiceIdentityResponse: r"""Generates the Cloud TPU service identity for the project. @@ -1118,8 +1164,10 @@ async def sample_generate_service_identity(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tpu_v2.types.GenerateServiceIdentityResponse: @@ -1166,7 +1214,7 @@ async def list_accelerator_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.ListAcceleratorTypesAsyncPager: r"""Lists accelerator types supported by this API. @@ -1209,8 +1257,10 @@ async def sample_list_accelerator_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.tpu_v2.services.tpu.pagers.ListAcceleratorTypesAsyncPager: @@ -1285,7 +1335,7 @@ async def get_accelerator_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]]] = (), ) -> cloud_tpu.AcceleratorType: r"""Gets AcceleratorType. @@ -1327,8 +1377,10 @@ async def sample_get_accelerator_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.tpu_v2.types.AcceleratorType: @@ -1389,7 +1441,7 @@ async def list_runtime_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.ListRuntimeVersionsAsyncPager: r"""Lists runtime versions supported by this API. @@ -1432,8 +1484,10 @@ async def sample_list_runtime_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.tpu_v2.services.tpu.pagers.ListRuntimeVersionsAsyncPager: @@ -1508,7 +1562,7 @@ async def get_runtime_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]]] = (), ) -> cloud_tpu.RuntimeVersion: r"""Gets a runtime version. @@ -1550,8 +1604,10 @@ async def sample_get_runtime_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.tpu_v2.types.RuntimeVersion: @@ -1611,7 +1667,7 @@ async def get_guest_attributes( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.GetGuestAttributesResponse: r"""Retrieves the guest attributes for the node. @@ -1648,8 +1704,10 @@ async def sample_get_guest_attributes(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tpu_v2.types.GetGuestAttributesResponse: @@ -1695,7 +1753,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. @@ -1706,8 +1764,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. @@ -1748,7 +1808,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. @@ -1759,8 +1819,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. @@ -1801,7 +1863,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. @@ -1817,8 +1879,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 """ @@ -1855,7 +1919,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. @@ -1870,8 +1934,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 """ @@ -1908,7 +1974,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. @@ -1919,8 +1985,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. @@ -1961,7 +2029,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. @@ -1972,8 +2040,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-tpu/google/cloud/tpu_v2/services/tpu/client.py b/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/client.py index 6a8b54f73ce8..67b951a51ffa 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/client.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/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 @@ -631,6 +641,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( @@ -691,6 +705,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.tpu_v2.TpuClient`.", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "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.tpu.v2.Tpu", + "credentialsType": None, + }, + ) + def list_nodes( self, request: Optional[Union[cloud_tpu.ListNodesRequest, dict]] = None, @@ -698,7 +735,7 @@ def list_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.ListNodesPager: r"""Lists nodes. @@ -741,8 +778,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.tpu_v2.services.tpu.pagers.ListNodesPager: @@ -814,7 +853,7 @@ def get_node( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.Node: r"""Gets the details of a node. @@ -855,8 +894,10 @@ def sample_get_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tpu_v2.types.Node: @@ -914,7 +955,7 @@ def create_node( node_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 node. @@ -974,8 +1015,10 @@ def sample_create_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1047,7 +1090,7 @@ def delete_node( name: Optional[str] = None, retry: OptionalRetry = gapic_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 node. @@ -1093,8 +1136,10 @@ def sample_delete_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1169,7 +1214,7 @@ def stop_node( *, retry: OptionalRetry = gapic_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"""Stops a node. This operation is only available with single TPU nodes. @@ -1211,8 +1256,10 @@ def sample_stop_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1266,7 +1313,7 @@ def start_node( *, retry: OptionalRetry = gapic_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"""Starts a node. @@ -1307,8 +1354,10 @@ def sample_start_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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 update_node( 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 configurations of a node. @@ -1423,8 +1472,10 @@ def sample_update_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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 generate_service_identity( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.GenerateServiceIdentityResponse: r"""Generates the Cloud TPU service identity for the project. @@ -1533,8 +1584,10 @@ def sample_generate_service_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.tpu_v2.types.GenerateServiceIdentityResponse: @@ -1581,7 +1634,7 @@ def list_accelerator_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.ListAcceleratorTypesPager: r"""Lists accelerator types supported by this API. @@ -1624,8 +1677,10 @@ def sample_list_accelerator_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.tpu_v2.services.tpu.pagers.ListAcceleratorTypesPager: @@ -1697,7 +1752,7 @@ def get_accelerator_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]]] = (), ) -> cloud_tpu.AcceleratorType: r"""Gets AcceleratorType. @@ -1739,8 +1794,10 @@ def sample_get_accelerator_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.tpu_v2.types.AcceleratorType: @@ -1798,7 +1855,7 @@ def list_runtime_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.ListRuntimeVersionsPager: r"""Lists runtime versions supported by this API. @@ -1841,8 +1898,10 @@ def sample_list_runtime_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.tpu_v2.services.tpu.pagers.ListRuntimeVersionsPager: @@ -1914,7 +1973,7 @@ def get_runtime_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]]] = (), ) -> cloud_tpu.RuntimeVersion: r"""Gets a runtime version. @@ -1956,8 +2015,10 @@ def sample_get_runtime_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.tpu_v2.types.RuntimeVersion: @@ -2014,7 +2075,7 @@ def get_guest_attributes( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.GetGuestAttributesResponse: r"""Retrieves the guest attributes for the node. @@ -2051,8 +2112,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.tpu_v2.types.GetGuestAttributesResponse: @@ -2109,7 +2172,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. @@ -2120,8 +2183,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. @@ -2162,7 +2227,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. @@ -2173,8 +2238,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. @@ -2215,7 +2282,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. @@ -2231,8 +2298,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 """ @@ -2269,7 +2338,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. @@ -2284,8 +2353,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 """ @@ -2322,7 +2393,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. @@ -2333,8 +2404,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. @@ -2375,7 +2448,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. @@ -2386,8 +2459,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-tpu/google/cloud/tpu_v2/services/tpu/pagers.py b/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/pagers.py index 62884a98b75c..bb2fa56c220a 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/pagers.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/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 = cloud_tpu.ListNodesRequest(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 = cloud_tpu.ListNodesRequest(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 = cloud_tpu.ListAcceleratorTypesRequest(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 = cloud_tpu.ListAcceleratorTypesRequest(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 = cloud_tpu.ListRuntimeVersionsRequest(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 = cloud_tpu.ListRuntimeVersionsRequest(request) diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/transports/grpc.py b/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/transports/grpc.py index b7022b377222..6c57707898ab 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/transports/grpc.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/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.tpu_v2.types import cloud_tpu from .base import DEFAULT_CLIENT_INFO, TpuTransport +try: + from google.api_core import client_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.tpu.v2.Tpu", + "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.tpu.v2.Tpu", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TpuGrpcTransport(TpuTransport): """gRPC backend transport for Tpu. @@ -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 @@ -272,7 +360,7 @@ def list_nodes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_nodes" not in self._stubs: - self._stubs["list_nodes"] = self.grpc_channel.unary_unary( + self._stubs["list_nodes"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/ListNodes", request_serializer=cloud_tpu.ListNodesRequest.serialize, response_deserializer=cloud_tpu.ListNodesResponse.deserialize, @@ -296,7 +384,7 @@ def get_node(self) -> Callable[[cloud_tpu.GetNodeRequest], cloud_tpu.Node]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_node" not in self._stubs: - self._stubs["get_node"] = self.grpc_channel.unary_unary( + self._stubs["get_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/GetNode", request_serializer=cloud_tpu.GetNodeRequest.serialize, response_deserializer=cloud_tpu.Node.deserialize, @@ -322,7 +410,7 @@ def create_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_node" not in self._stubs: - self._stubs["create_node"] = self.grpc_channel.unary_unary( + self._stubs["create_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/CreateNode", request_serializer=cloud_tpu.CreateNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -348,7 +436,7 @@ def delete_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_node" not in self._stubs: - self._stubs["delete_node"] = self.grpc_channel.unary_unary( + self._stubs["delete_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/DeleteNode", request_serializer=cloud_tpu.DeleteNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -375,7 +463,7 @@ def stop_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_node" not in self._stubs: - self._stubs["stop_node"] = self.grpc_channel.unary_unary( + self._stubs["stop_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/StopNode", request_serializer=cloud_tpu.StopNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -401,7 +489,7 @@ def start_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_node" not in self._stubs: - self._stubs["start_node"] = self.grpc_channel.unary_unary( + self._stubs["start_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/StartNode", request_serializer=cloud_tpu.StartNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -427,7 +515,7 @@ def update_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_node" not in self._stubs: - self._stubs["update_node"] = self.grpc_channel.unary_unary( + self._stubs["update_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/UpdateNode", request_serializer=cloud_tpu.UpdateNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -457,7 +545,7 @@ def generate_service_identity( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_service_identity" not in self._stubs: - self._stubs["generate_service_identity"] = self.grpc_channel.unary_unary( + self._stubs["generate_service_identity"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/GenerateServiceIdentity", request_serializer=cloud_tpu.GenerateServiceIdentityRequest.serialize, response_deserializer=cloud_tpu.GenerateServiceIdentityResponse.deserialize, @@ -485,7 +573,7 @@ def list_accelerator_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_accelerator_types" not in self._stubs: - self._stubs["list_accelerator_types"] = self.grpc_channel.unary_unary( + self._stubs["list_accelerator_types"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/ListAcceleratorTypes", request_serializer=cloud_tpu.ListAcceleratorTypesRequest.serialize, response_deserializer=cloud_tpu.ListAcceleratorTypesResponse.deserialize, @@ -511,7 +599,7 @@ def get_accelerator_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_accelerator_type" not in self._stubs: - self._stubs["get_accelerator_type"] = self.grpc_channel.unary_unary( + self._stubs["get_accelerator_type"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/GetAcceleratorType", request_serializer=cloud_tpu.GetAcceleratorTypeRequest.serialize, response_deserializer=cloud_tpu.AcceleratorType.deserialize, @@ -539,7 +627,7 @@ def list_runtime_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_runtime_versions" not in self._stubs: - self._stubs["list_runtime_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_runtime_versions"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/ListRuntimeVersions", request_serializer=cloud_tpu.ListRuntimeVersionsRequest.serialize, response_deserializer=cloud_tpu.ListRuntimeVersionsResponse.deserialize, @@ -565,7 +653,7 @@ def get_runtime_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_runtime_version" not in self._stubs: - self._stubs["get_runtime_version"] = self.grpc_channel.unary_unary( + self._stubs["get_runtime_version"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/GetRuntimeVersion", request_serializer=cloud_tpu.GetRuntimeVersionRequest.serialize, response_deserializer=cloud_tpu.RuntimeVersion.deserialize, @@ -593,7 +681,7 @@ def get_guest_attributes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_guest_attributes" not in self._stubs: - self._stubs["get_guest_attributes"] = self.grpc_channel.unary_unary( + self._stubs["get_guest_attributes"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/GetGuestAttributes", request_serializer=cloud_tpu.GetGuestAttributesRequest.serialize, response_deserializer=cloud_tpu.GetGuestAttributesResponse.deserialize, @@ -601,7 +689,7 @@ def get_guest_attributes( return self._stubs["get_guest_attributes"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -613,7 +701,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, @@ -630,7 +718,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, @@ -647,7 +735,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, @@ -666,7 +754,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, @@ -685,7 +773,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, @@ -702,7 +790,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-tpu/google/cloud/tpu_v2/services/tpu/transports/grpc_asyncio.py b/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/transports/grpc_asyncio.py index 36ca488a5cf5..ae51d9091420 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/transports/grpc_asyncio.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/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.tpu_v2.types import cloud_tpu from .base import DEFAULT_CLIENT_INFO, TpuTransport from .grpc import TpuGrpcTransport +try: + from google.api_core import client_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.tpu.v2.Tpu", + "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.tpu.v2.Tpu", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TpuGrpcAsyncIOTransport(TpuTransport): """gRPC AsyncIO backend transport for Tpu. @@ -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. @@ -282,7 +367,7 @@ def list_nodes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_nodes" not in self._stubs: - self._stubs["list_nodes"] = self.grpc_channel.unary_unary( + self._stubs["list_nodes"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/ListNodes", request_serializer=cloud_tpu.ListNodesRequest.serialize, response_deserializer=cloud_tpu.ListNodesResponse.deserialize, @@ -308,7 +393,7 @@ def get_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_node" not in self._stubs: - self._stubs["get_node"] = self.grpc_channel.unary_unary( + self._stubs["get_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/GetNode", request_serializer=cloud_tpu.GetNodeRequest.serialize, response_deserializer=cloud_tpu.Node.deserialize, @@ -334,7 +419,7 @@ def create_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_node" not in self._stubs: - self._stubs["create_node"] = self.grpc_channel.unary_unary( + self._stubs["create_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/CreateNode", request_serializer=cloud_tpu.CreateNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -360,7 +445,7 @@ def delete_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_node" not in self._stubs: - self._stubs["delete_node"] = self.grpc_channel.unary_unary( + self._stubs["delete_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/DeleteNode", request_serializer=cloud_tpu.DeleteNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -387,7 +472,7 @@ def stop_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_node" not in self._stubs: - self._stubs["stop_node"] = self.grpc_channel.unary_unary( + self._stubs["stop_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/StopNode", request_serializer=cloud_tpu.StopNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -413,7 +498,7 @@ def start_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_node" not in self._stubs: - self._stubs["start_node"] = self.grpc_channel.unary_unary( + self._stubs["start_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/StartNode", request_serializer=cloud_tpu.StartNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -439,7 +524,7 @@ def update_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_node" not in self._stubs: - self._stubs["update_node"] = self.grpc_channel.unary_unary( + self._stubs["update_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/UpdateNode", request_serializer=cloud_tpu.UpdateNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -469,7 +554,7 @@ def generate_service_identity( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_service_identity" not in self._stubs: - self._stubs["generate_service_identity"] = self.grpc_channel.unary_unary( + self._stubs["generate_service_identity"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/GenerateServiceIdentity", request_serializer=cloud_tpu.GenerateServiceIdentityRequest.serialize, response_deserializer=cloud_tpu.GenerateServiceIdentityResponse.deserialize, @@ -498,7 +583,7 @@ def list_accelerator_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_accelerator_types" not in self._stubs: - self._stubs["list_accelerator_types"] = self.grpc_channel.unary_unary( + self._stubs["list_accelerator_types"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/ListAcceleratorTypes", request_serializer=cloud_tpu.ListAcceleratorTypesRequest.serialize, response_deserializer=cloud_tpu.ListAcceleratorTypesResponse.deserialize, @@ -526,7 +611,7 @@ def get_accelerator_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_accelerator_type" not in self._stubs: - self._stubs["get_accelerator_type"] = self.grpc_channel.unary_unary( + self._stubs["get_accelerator_type"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/GetAcceleratorType", request_serializer=cloud_tpu.GetAcceleratorTypeRequest.serialize, response_deserializer=cloud_tpu.AcceleratorType.deserialize, @@ -555,7 +640,7 @@ def list_runtime_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_runtime_versions" not in self._stubs: - self._stubs["list_runtime_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_runtime_versions"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/ListRuntimeVersions", request_serializer=cloud_tpu.ListRuntimeVersionsRequest.serialize, response_deserializer=cloud_tpu.ListRuntimeVersionsResponse.deserialize, @@ -583,7 +668,7 @@ def get_runtime_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_runtime_version" not in self._stubs: - self._stubs["get_runtime_version"] = self.grpc_channel.unary_unary( + self._stubs["get_runtime_version"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/GetRuntimeVersion", request_serializer=cloud_tpu.GetRuntimeVersionRequest.serialize, response_deserializer=cloud_tpu.RuntimeVersion.deserialize, @@ -612,7 +697,7 @@ def get_guest_attributes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_guest_attributes" not in self._stubs: - self._stubs["get_guest_attributes"] = self.grpc_channel.unary_unary( + self._stubs["get_guest_attributes"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/GetGuestAttributes", request_serializer=cloud_tpu.GetGuestAttributesRequest.serialize, response_deserializer=cloud_tpu.GetGuestAttributesResponse.deserialize, @@ -725,7 +810,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: @@ -741,7 +826,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, @@ -758,7 +843,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, @@ -775,7 +860,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, @@ -794,7 +879,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, @@ -813,7 +898,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, @@ -830,7 +915,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-tpu/google/cloud/tpu_v2/services/tpu/transports/rest.py b/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/transports/rest.py index 98acc2888356..d503b356ff39 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/transports/rest.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/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, @@ -173,8 +181,10 @@ def post_update_node(self, response): """ def pre_create_node( - self, request: cloud_tpu.CreateNodeRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloud_tpu.CreateNodeRequest, Sequence[Tuple[str, str]]]: + self, + request: cloud_tpu.CreateNodeRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloud_tpu.CreateNodeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_node Override in a subclass to manipulate the request or metadata @@ -194,8 +204,10 @@ def post_create_node( return response def pre_delete_node( - self, request: cloud_tpu.DeleteNodeRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloud_tpu.DeleteNodeRequest, Sequence[Tuple[str, str]]]: + self, + request: cloud_tpu.DeleteNodeRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloud_tpu.DeleteNodeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_node Override in a subclass to manipulate the request or metadata @@ -217,8 +229,11 @@ def post_delete_node( def pre_generate_service_identity( self, request: cloud_tpu.GenerateServiceIdentityRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_tpu.GenerateServiceIdentityRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_tpu.GenerateServiceIdentityRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for generate_service_identity Override in a subclass to manipulate the request or metadata @@ -240,8 +255,10 @@ def post_generate_service_identity( def pre_get_accelerator_type( self, request: cloud_tpu.GetAcceleratorTypeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_tpu.GetAcceleratorTypeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_tpu.GetAcceleratorTypeRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_accelerator_type Override in a subclass to manipulate the request or metadata @@ -263,8 +280,10 @@ def post_get_accelerator_type( def pre_get_guest_attributes( self, request: cloud_tpu.GetGuestAttributesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_tpu.GetGuestAttributesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_tpu.GetGuestAttributesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_guest_attributes Override in a subclass to manipulate the request or metadata @@ -284,8 +303,10 @@ def post_get_guest_attributes( return response def pre_get_node( - self, request: cloud_tpu.GetNodeRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloud_tpu.GetNodeRequest, Sequence[Tuple[str, str]]]: + self, + request: cloud_tpu.GetNodeRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloud_tpu.GetNodeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_node Override in a subclass to manipulate the request or metadata @@ -305,8 +326,10 @@ def post_get_node(self, response: cloud_tpu.Node) -> cloud_tpu.Node: def pre_get_runtime_version( self, request: cloud_tpu.GetRuntimeVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_tpu.GetRuntimeVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_tpu.GetRuntimeVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_runtime_version Override in a subclass to manipulate the request or metadata @@ -328,8 +351,10 @@ def post_get_runtime_version( def pre_list_accelerator_types( self, request: cloud_tpu.ListAcceleratorTypesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_tpu.ListAcceleratorTypesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_tpu.ListAcceleratorTypesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_accelerator_types Override in a subclass to manipulate the request or metadata @@ -349,8 +374,10 @@ def post_list_accelerator_types( return response def pre_list_nodes( - self, request: cloud_tpu.ListNodesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloud_tpu.ListNodesRequest, Sequence[Tuple[str, str]]]: + self, + request: cloud_tpu.ListNodesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloud_tpu.ListNodesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_nodes Override in a subclass to manipulate the request or metadata @@ -372,8 +399,10 @@ def post_list_nodes( def pre_list_runtime_versions( self, request: cloud_tpu.ListRuntimeVersionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_tpu.ListRuntimeVersionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_tpu.ListRuntimeVersionsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_runtime_versions Override in a subclass to manipulate the request or metadata @@ -393,8 +422,10 @@ def post_list_runtime_versions( return response def pre_start_node( - self, request: cloud_tpu.StartNodeRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloud_tpu.StartNodeRequest, Sequence[Tuple[str, str]]]: + self, + request: cloud_tpu.StartNodeRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloud_tpu.StartNodeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for start_node Override in a subclass to manipulate the request or metadata @@ -414,8 +445,10 @@ def post_start_node( return response def pre_stop_node( - self, request: cloud_tpu.StopNodeRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloud_tpu.StopNodeRequest, Sequence[Tuple[str, str]]]: + self, + request: cloud_tpu.StopNodeRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloud_tpu.StopNodeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for stop_node Override in a subclass to manipulate the request or metadata @@ -435,8 +468,10 @@ def post_stop_node( return response def pre_update_node( - self, request: cloud_tpu.UpdateNodeRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloud_tpu.UpdateNodeRequest, Sequence[Tuple[str, str]]]: + self, + request: cloud_tpu.UpdateNodeRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloud_tpu.UpdateNodeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_node Override in a subclass to manipulate the request or metadata @@ -458,8 +493,10 @@ def post_update_node( 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 @@ -481,8 +518,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 @@ -504,8 +543,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 @@ -525,8 +566,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 @@ -546,8 +589,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 @@ -569,8 +614,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 @@ -764,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create node method over HTTP. @@ -775,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: @@ -787,6 +836,7 @@ def __call__( """ http_options = _BaseTpuRestTransport._BaseCreateNode._get_http_options() + request, metadata = self._interceptor.pre_create_node(request, metadata) transcoded_request = ( _BaseTpuRestTransport._BaseCreateNode._get_transcoded_request( @@ -803,6 +853,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tpu_v2.TpuClient.CreateNode", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "CreateNode", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._CreateNode._get_response( self._host, @@ -822,7 +899,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_node(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tpu_v2.TpuClient.create_node", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "CreateNode", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteNode(_BaseTpuRestTransport._BaseDeleteNode, TpuRestStub): @@ -857,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete node method over HTTP. @@ -868,8 +967,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -880,6 +981,7 @@ def __call__( """ http_options = _BaseTpuRestTransport._BaseDeleteNode._get_http_options() + request, metadata = self._interceptor.pre_delete_node(request, metadata) transcoded_request = ( _BaseTpuRestTransport._BaseDeleteNode._get_transcoded_request( @@ -892,6 +994,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tpu_v2.TpuClient.DeleteNode", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "DeleteNode", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._DeleteNode._get_response( self._host, @@ -910,7 +1039,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_node(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tpu_v2.TpuClient.delete_node", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "DeleteNode", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateServiceIdentity( @@ -948,7 +1099,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.GenerateServiceIdentityResponse: r"""Call the generate service identity method over HTTP. @@ -959,8 +1110,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloud_tpu.GenerateServiceIdentityResponse: @@ -972,6 +1125,7 @@ def __call__( http_options = ( _BaseTpuRestTransport._BaseGenerateServiceIdentity._get_http_options() ) + request, metadata = self._interceptor.pre_generate_service_identity( request, metadata ) @@ -988,6 +1142,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tpu_v2.TpuClient.GenerateServiceIdentity", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GenerateServiceIdentity", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._GenerateServiceIdentity._get_response( self._host, @@ -1009,7 +1190,31 @@ def __call__( pb_resp = cloud_tpu.GenerateServiceIdentityResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_service_identity(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + cloud_tpu.GenerateServiceIdentityResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tpu_v2.TpuClient.generate_service_identity", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GenerateServiceIdentity", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAcceleratorType( @@ -1046,7 +1251,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.AcceleratorType: r"""Call the get accelerator type method over HTTP. @@ -1057,8 +1262,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloud_tpu.AcceleratorType: @@ -1070,6 +1277,7 @@ def __call__( http_options = ( _BaseTpuRestTransport._BaseGetAcceleratorType._get_http_options() ) + request, metadata = self._interceptor.pre_get_accelerator_type( request, metadata ) @@ -1086,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.tpu_v2.TpuClient.GetAcceleratorType", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GetAcceleratorType", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._GetAcceleratorType._get_response( self._host, @@ -1106,7 +1341,29 @@ def __call__( pb_resp = cloud_tpu.AcceleratorType.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_accelerator_type(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_tpu.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.tpu_v2.TpuClient.get_accelerator_type", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GetAcceleratorType", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetGuestAttributes( @@ -1144,7 +1401,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.GetGuestAttributesResponse: r"""Call the get guest attributes method over HTTP. @@ -1155,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: ~.cloud_tpu.GetGuestAttributesResponse: @@ -1168,6 +1427,7 @@ def __call__( http_options = ( _BaseTpuRestTransport._BaseGetGuestAttributes._get_http_options() ) + request, metadata = self._interceptor.pre_get_guest_attributes( request, metadata ) @@ -1188,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.tpu_v2.TpuClient.GetGuestAttributes", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GetGuestAttributes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._GetGuestAttributes._get_response( self._host, @@ -1209,7 +1496,31 @@ def __call__( pb_resp = cloud_tpu.GetGuestAttributesResponse.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 = cloud_tpu.GetGuestAttributesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tpu_v2.TpuClient.get_guest_attributes", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GetGuestAttributes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetNode(_BaseTpuRestTransport._BaseGetNode, TpuRestStub): @@ -1244,7 +1555,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.Node: r"""Call the get node method over HTTP. @@ -1254,8 +1565,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloud_tpu.Node: @@ -1263,6 +1576,7 @@ def __call__( """ http_options = _BaseTpuRestTransport._BaseGetNode._get_http_options() + request, metadata = self._interceptor.pre_get_node(request, metadata) transcoded_request = ( _BaseTpuRestTransport._BaseGetNode._get_transcoded_request( @@ -1275,6 +1589,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tpu_v2.TpuClient.GetNode", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GetNode", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._GetNode._get_response( self._host, @@ -1295,7 +1636,29 @@ def __call__( pb_resp = cloud_tpu.Node.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_node(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_tpu.Node.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tpu_v2.TpuClient.get_node", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GetNode", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetRuntimeVersion(_BaseTpuRestTransport._BaseGetRuntimeVersion, TpuRestStub): @@ -1330,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]]] = (), ) -> cloud_tpu.RuntimeVersion: r"""Call the get runtime version method over HTTP. @@ -1341,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: ~.cloud_tpu.RuntimeVersion: @@ -1354,6 +1719,7 @@ def __call__( http_options = ( _BaseTpuRestTransport._BaseGetRuntimeVersion._get_http_options() ) + request, metadata = self._interceptor.pre_get_runtime_version( request, metadata ) @@ -1370,6 +1736,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tpu_v2.TpuClient.GetRuntimeVersion", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GetRuntimeVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._GetRuntimeVersion._get_response( self._host, @@ -1390,7 +1783,29 @@ def __call__( pb_resp = cloud_tpu.RuntimeVersion.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_runtime_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_tpu.RuntimeVersion.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tpu_v2.TpuClient.get_runtime_version", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GetRuntimeVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAcceleratorTypes( @@ -1427,7 +1842,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.ListAcceleratorTypesResponse: r"""Call the list accelerator types method over HTTP. @@ -1438,8 +1853,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloud_tpu.ListAcceleratorTypesResponse: @@ -1451,6 +1868,7 @@ def __call__( http_options = ( _BaseTpuRestTransport._BaseListAcceleratorTypes._get_http_options() ) + request, metadata = self._interceptor.pre_list_accelerator_types( request, metadata ) @@ -1467,6 +1885,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tpu_v2.TpuClient.ListAcceleratorTypes", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "ListAcceleratorTypes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._ListAcceleratorTypes._get_response( self._host, @@ -1487,7 +1932,31 @@ def __call__( pb_resp = cloud_tpu.ListAcceleratorTypesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_accelerator_types(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_tpu.ListAcceleratorTypesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tpu_v2.TpuClient.list_accelerator_types", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "ListAcceleratorTypes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListNodes(_BaseTpuRestTransport._BaseListNodes, TpuRestStub): @@ -1522,7 +1991,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.ListNodesResponse: r"""Call the list nodes method over HTTP. @@ -1533,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: ~.cloud_tpu.ListNodesResponse: @@ -1544,6 +2015,7 @@ def __call__( """ http_options = _BaseTpuRestTransport._BaseListNodes._get_http_options() + request, metadata = self._interceptor.pre_list_nodes(request, metadata) transcoded_request = ( _BaseTpuRestTransport._BaseListNodes._get_transcoded_request( @@ -1556,6 +2028,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tpu_v2.TpuClient.ListNodes", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "ListNodes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._ListNodes._get_response( self._host, @@ -1576,7 +2075,29 @@ def __call__( pb_resp = cloud_tpu.ListNodesResponse.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 = cloud_tpu.ListNodesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tpu_v2.TpuClient.list_nodes", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "ListNodes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListRuntimeVersions( @@ -1613,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]]] = (), ) -> cloud_tpu.ListRuntimeVersionsResponse: r"""Call the list runtime versions method over HTTP. @@ -1624,8 +2145,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloud_tpu.ListRuntimeVersionsResponse: @@ -1637,6 +2160,7 @@ def __call__( http_options = ( _BaseTpuRestTransport._BaseListRuntimeVersions._get_http_options() ) + request, metadata = self._interceptor.pre_list_runtime_versions( request, metadata ) @@ -1653,6 +2177,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tpu_v2.TpuClient.ListRuntimeVersions", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "ListRuntimeVersions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._ListRuntimeVersions._get_response( self._host, @@ -1673,7 +2224,31 @@ def __call__( pb_resp = cloud_tpu.ListRuntimeVersionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_runtime_versions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_tpu.ListRuntimeVersionsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tpu_v2.TpuClient.list_runtime_versions", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "ListRuntimeVersions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StartNode(_BaseTpuRestTransport._BaseStartNode, TpuRestStub): @@ -1709,7 +2284,7 @@ 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 start node method over HTTP. @@ -1720,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: ~.operations_pb2.Operation: @@ -1732,6 +2309,7 @@ def __call__( """ http_options = _BaseTpuRestTransport._BaseStartNode._get_http_options() + request, metadata = self._interceptor.pre_start_node(request, metadata) transcoded_request = ( _BaseTpuRestTransport._BaseStartNode._get_transcoded_request( @@ -1748,6 +2326,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tpu_v2.TpuClient.StartNode", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "StartNode", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._StartNode._get_response( self._host, @@ -1767,7 +2372,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_start_node(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tpu_v2.TpuClient.start_node", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "StartNode", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StopNode(_BaseTpuRestTransport._BaseStopNode, TpuRestStub): @@ -1803,7 +2430,7 @@ 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 stop node method over HTTP. @@ -1814,8 +2441,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1826,6 +2455,7 @@ def __call__( """ http_options = _BaseTpuRestTransport._BaseStopNode._get_http_options() + request, metadata = self._interceptor.pre_stop_node(request, metadata) transcoded_request = ( _BaseTpuRestTransport._BaseStopNode._get_transcoded_request( @@ -1842,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.tpu_v2.TpuClient.StopNode", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "StopNode", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._StopNode._get_response( self._host, @@ -1861,7 +2518,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_stop_node(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tpu_v2.TpuClient.stop_node", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "StopNode", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateNode(_BaseTpuRestTransport._BaseUpdateNode, TpuRestStub): @@ -1897,7 +2576,7 @@ 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 node method over HTTP. @@ -1908,8 +2587,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1920,6 +2601,7 @@ def __call__( """ http_options = _BaseTpuRestTransport._BaseUpdateNode._get_http_options() + request, metadata = self._interceptor.pre_update_node(request, metadata) transcoded_request = ( _BaseTpuRestTransport._BaseUpdateNode._get_transcoded_request( @@ -1936,6 +2618,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tpu_v2.TpuClient.UpdateNode", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "UpdateNode", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._UpdateNode._get_response( self._host, @@ -1955,7 +2664,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_node(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tpu_v2.TpuClient.update_node", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "UpdateNode", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -2105,7 +2836,7 @@ 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. @@ -2115,14 +2846,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 = _BaseTpuRestTransport._BaseGetLocation._get_http_options() + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseTpuRestTransport._BaseGetLocation._get_transcoded_request( @@ -2137,6 +2871,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tpu_v2.TpuClient.GetLocation", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._GetLocation._get_response( self._host, @@ -2156,6 +2917,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.tpu_v2.TpuAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2194,7 +2976,7 @@ 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. @@ -2204,14 +2986,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.ListLocationsResponse: Response from ListLocations method. """ http_options = _BaseTpuRestTransport._BaseListLocations._get_http_options() + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseTpuRestTransport._BaseListLocations._get_transcoded_request( @@ -2226,6 +3011,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tpu_v2.TpuClient.ListLocations", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._ListLocations._get_response( self._host, @@ -2245,6 +3057,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.tpu_v2.TpuAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2283,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -2293,13 +3126,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 = ( _BaseTpuRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -2316,6 +3152,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tpu_v2.TpuClient.CancelOperation", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._CancelOperation._get_response( self._host, @@ -2369,7 +3232,7 @@ 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 +3242,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 = ( _BaseTpuRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -2402,6 +3268,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tpu_v2.TpuClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._DeleteOperation._get_response( self._host, @@ -2455,7 +3348,7 @@ 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. @@ -2465,14 +3358,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: operations_pb2.Operation: Response from GetOperation method. """ http_options = _BaseTpuRestTransport._BaseGetOperation._get_http_options() + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseTpuRestTransport._BaseGetOperation._get_transcoded_request( @@ -2487,6 +3383,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tpu_v2.TpuClient.GetOperation", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._GetOperation._get_response( self._host, @@ -2506,6 +3429,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.tpu_v2.TpuAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2544,7 +3488,7 @@ 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,14 +3498,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. """ http_options = _BaseTpuRestTransport._BaseListOperations._get_http_options() + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseTpuRestTransport._BaseListOperations._get_transcoded_request( @@ -2576,6 +3523,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tpu_v2.TpuClient.ListOperations", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._ListOperations._get_response( self._host, @@ -2595,6 +3569,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.tpu_v2.TpuAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/gapic_version.py b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/gapic_version.py index 68899264edad..558c8aab67c5 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/gapic_version.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.19.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/async_client.py b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/async_client.py index 61e18600e7a2..131504f9fccd 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/async_client.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/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, TpuTransport from .transports.grpc_asyncio import TpuGrpcAsyncIOTransport +try: + from google.api_core import client_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 TpuAsyncClient: """Manages TPU nodes and other resources @@ -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.tpu_v2alpha1.TpuAsyncClient`.", + extra={ + "serviceName": "google.cloud.tpu.v2alpha1.Tpu", + "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.tpu.v2alpha1.Tpu", + "credentialsType": None, + }, + ) + async def list_nodes( self, request: Optional[Union[cloud_tpu.ListNodesRequest, dict]] = None, @@ -268,7 +300,7 @@ async def list_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.ListNodesAsyncPager: r"""Lists nodes. @@ -311,8 +343,10 @@ async def sample_list_nodes(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tpu_v2alpha1.services.tpu.pagers.ListNodesAsyncPager: @@ -387,7 +421,7 @@ async def get_node( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.Node: r"""Gets the details of a node. @@ -429,8 +463,10 @@ async def sample_get_node(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tpu_v2alpha1.types.Node: @@ -489,7 +525,7 @@ async def create_node( node_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 node. @@ -549,8 +585,10 @@ async def sample_create_node(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -626,7 +664,7 @@ async def delete_node( name: Optional[str] = None, retry: OptionalRetry = gapic_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 node. @@ -672,8 +710,10 @@ async def sample_delete_node(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -751,7 +791,7 @@ async def stop_node( *, retry: OptionalRetry = gapic_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"""Stops a node. This operation is only available with single TPU nodes. @@ -793,8 +833,10 @@ async def sample_stop_node(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -851,7 +893,7 @@ async def start_node( *, retry: OptionalRetry = gapic_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"""Starts a node. @@ -892,8 +934,10 @@ async def sample_start_node(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -952,7 +996,7 @@ async def update_node( 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 configurations of a node. @@ -1011,8 +1055,10 @@ async def sample_update_node(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1088,7 +1134,7 @@ async def list_queued_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.ListQueuedResourcesAsyncPager: r"""Lists queued resources. @@ -1131,8 +1177,10 @@ async def sample_list_queued_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.tpu_v2alpha1.services.tpu.pagers.ListQueuedResourcesAsyncPager: @@ -1207,7 +1255,7 @@ async def get_queued_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]]] = (), ) -> cloud_tpu.QueuedResource: r"""Gets details of a queued resource. @@ -1249,8 +1297,10 @@ async def sample_get_queued_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.tpu_v2alpha1.types.QueuedResource: @@ -1315,7 +1365,7 @@ async def create_queued_resource( queued_resource_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 QueuedResource TPU instance. @@ -1373,8 +1423,10 @@ async def sample_create_queued_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.api_core.operation_async.AsyncOperation: @@ -1450,7 +1502,7 @@ async def delete_queued_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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a QueuedResource TPU instance. @@ -1496,8 +1548,10 @@ async def sample_delete_queued_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.api_core.operation_async.AsyncOperation: @@ -1569,7 +1623,7 @@ async def reset_queued_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]]] = (), ) -> operation_async.AsyncOperation: r"""Resets a QueuedResource TPU instance @@ -1617,8 +1671,10 @@ async def sample_reset_queued_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.api_core.operation_async.AsyncOperation: @@ -1689,7 +1745,7 @@ async def generate_service_identity( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.GenerateServiceIdentityResponse: r"""Generates the Cloud TPU service identity for the project. @@ -1727,8 +1783,10 @@ async def sample_generate_service_identity(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tpu_v2alpha1.types.GenerateServiceIdentityResponse: @@ -1775,7 +1833,7 @@ async def list_accelerator_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.ListAcceleratorTypesAsyncPager: r"""Lists accelerator types supported by this API. @@ -1818,8 +1876,10 @@ async def sample_list_accelerator_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.tpu_v2alpha1.services.tpu.pagers.ListAcceleratorTypesAsyncPager: @@ -1894,7 +1954,7 @@ async def get_accelerator_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]]] = (), ) -> cloud_tpu.AcceleratorType: r"""Gets AcceleratorType. @@ -1936,8 +1996,10 @@ async def sample_get_accelerator_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.tpu_v2alpha1.types.AcceleratorType: @@ -1998,7 +2060,7 @@ async def list_runtime_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.ListRuntimeVersionsAsyncPager: r"""Lists runtime versions supported by this API. @@ -2041,8 +2103,10 @@ async def sample_list_runtime_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.tpu_v2alpha1.services.tpu.pagers.ListRuntimeVersionsAsyncPager: @@ -2117,7 +2181,7 @@ async def get_runtime_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]]] = (), ) -> cloud_tpu.RuntimeVersion: r"""Gets a runtime version. @@ -2159,8 +2223,10 @@ async def sample_get_runtime_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.tpu_v2alpha1.types.RuntimeVersion: @@ -2220,7 +2286,7 @@ async def get_guest_attributes( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.GetGuestAttributesResponse: r"""Retrieves the guest attributes for the node. @@ -2257,8 +2323,10 @@ async def sample_get_guest_attributes(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tpu_v2alpha1.types.GetGuestAttributesResponse: @@ -2306,7 +2374,7 @@ async def simulate_maintenance_event( *, retry: OptionalRetry = gapic_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"""Simulates a maintenance event. @@ -2347,8 +2415,10 @@ async def sample_simulate_maintenance_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.api_core.operation_async.AsyncOperation: @@ -2405,7 +2475,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. @@ -2416,8 +2486,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. @@ -2458,7 +2530,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. @@ -2469,8 +2541,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. @@ -2511,7 +2585,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. @@ -2527,8 +2601,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 """ @@ -2565,7 +2641,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. @@ -2580,8 +2656,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 """ @@ -2618,7 +2696,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. @@ -2629,8 +2707,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. @@ -2671,7 +2751,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. @@ -2682,8 +2762,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-tpu/google/cloud/tpu_v2alpha1/services/tpu/client.py b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/client.py index 23ed6f5401f7..49fd1a0bdf62 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/client.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/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 @@ -651,6 +661,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( @@ -711,6 +725,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.tpu_v2alpha1.TpuClient`.", + extra={ + "serviceName": "google.cloud.tpu.v2alpha1.Tpu", + "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.tpu.v2alpha1.Tpu", + "credentialsType": None, + }, + ) + def list_nodes( self, request: Optional[Union[cloud_tpu.ListNodesRequest, dict]] = None, @@ -718,7 +755,7 @@ def list_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.ListNodesPager: r"""Lists nodes. @@ -761,8 +798,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.tpu_v2alpha1.services.tpu.pagers.ListNodesPager: @@ -834,7 +873,7 @@ def get_node( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.Node: r"""Gets the details of a node. @@ -876,8 +915,10 @@ def sample_get_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tpu_v2alpha1.types.Node: @@ -935,7 +976,7 @@ def create_node( node_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 node. @@ -995,8 +1036,10 @@ def sample_create_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1069,7 +1112,7 @@ def delete_node( name: Optional[str] = None, retry: OptionalRetry = gapic_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 node. @@ -1115,8 +1158,10 @@ def sample_delete_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1191,7 +1236,7 @@ def stop_node( *, retry: OptionalRetry = gapic_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"""Stops a node. This operation is only available with single TPU nodes. @@ -1233,8 +1278,10 @@ def sample_stop_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1289,7 +1336,7 @@ def start_node( *, retry: OptionalRetry = gapic_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"""Starts a node. @@ -1330,8 +1377,10 @@ def sample_start_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1388,7 +1437,7 @@ def update_node( 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 configurations of a node. @@ -1447,8 +1496,10 @@ def sample_update_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1521,7 +1572,7 @@ def list_queued_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.ListQueuedResourcesPager: r"""Lists queued resources. @@ -1564,8 +1615,10 @@ def sample_list_queued_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.tpu_v2alpha1.services.tpu.pagers.ListQueuedResourcesPager: @@ -1637,7 +1690,7 @@ def get_queued_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]]] = (), ) -> cloud_tpu.QueuedResource: r"""Gets details of a queued resource. @@ -1679,8 +1732,10 @@ def sample_get_queued_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.tpu_v2alpha1.types.QueuedResource: @@ -1742,7 +1797,7 @@ def create_queued_resource( queued_resource_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 QueuedResource TPU instance. @@ -1800,8 +1855,10 @@ def sample_create_queued_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.operation.Operation: @@ -1874,7 +1931,7 @@ def delete_queued_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]]] = (), ) -> operation.Operation: r"""Deletes a QueuedResource TPU instance. @@ -1920,8 +1977,10 @@ def sample_delete_queued_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.operation.Operation: @@ -1990,7 +2049,7 @@ def reset_queued_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]]] = (), ) -> operation.Operation: r"""Resets a QueuedResource TPU instance @@ -2038,8 +2097,10 @@ def sample_reset_queued_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.operation.Operation: @@ -2107,7 +2168,7 @@ def generate_service_identity( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.GenerateServiceIdentityResponse: r"""Generates the Cloud TPU service identity for the project. @@ -2145,8 +2206,10 @@ def sample_generate_service_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.tpu_v2alpha1.types.GenerateServiceIdentityResponse: @@ -2193,7 +2256,7 @@ def list_accelerator_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.ListAcceleratorTypesPager: r"""Lists accelerator types supported by this API. @@ -2236,8 +2299,10 @@ def sample_list_accelerator_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.tpu_v2alpha1.services.tpu.pagers.ListAcceleratorTypesPager: @@ -2309,7 +2374,7 @@ def get_accelerator_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]]] = (), ) -> cloud_tpu.AcceleratorType: r"""Gets AcceleratorType. @@ -2351,8 +2416,10 @@ def sample_get_accelerator_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.tpu_v2alpha1.types.AcceleratorType: @@ -2410,7 +2477,7 @@ def list_runtime_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.ListRuntimeVersionsPager: r"""Lists runtime versions supported by this API. @@ -2453,8 +2520,10 @@ def sample_list_runtime_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.tpu_v2alpha1.services.tpu.pagers.ListRuntimeVersionsPager: @@ -2526,7 +2595,7 @@ def get_runtime_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]]] = (), ) -> cloud_tpu.RuntimeVersion: r"""Gets a runtime version. @@ -2568,8 +2637,10 @@ def sample_get_runtime_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.tpu_v2alpha1.types.RuntimeVersion: @@ -2626,7 +2697,7 @@ def get_guest_attributes( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.GetGuestAttributesResponse: r"""Retrieves the guest attributes for the node. @@ -2663,8 +2734,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.tpu_v2alpha1.types.GetGuestAttributesResponse: @@ -2710,7 +2783,7 @@ def simulate_maintenance_event( *, retry: OptionalRetry = gapic_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"""Simulates a maintenance event. @@ -2751,8 +2824,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.operation.Operation: @@ -2822,7 +2897,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. @@ -2833,8 +2908,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. @@ -2875,7 +2952,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. @@ -2886,8 +2963,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. @@ -2928,7 +3007,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. @@ -2944,8 +3023,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 """ @@ -2982,7 +3063,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. @@ -2997,8 +3078,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 """ @@ -3035,7 +3118,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. @@ -3046,8 +3129,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. @@ -3088,7 +3173,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. @@ -3099,8 +3184,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-tpu/google/cloud/tpu_v2alpha1/services/tpu/pagers.py b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/pagers.py index 05da2e89ee66..c82a208419fb 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/pagers.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/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 = cloud_tpu.ListNodesRequest(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 = cloud_tpu.ListNodesRequest(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 = cloud_tpu.ListQueuedResourcesRequest(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 = cloud_tpu.ListQueuedResourcesRequest(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 = cloud_tpu.ListAcceleratorTypesRequest(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 = cloud_tpu.ListAcceleratorTypesRequest(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 = cloud_tpu.ListRuntimeVersionsRequest(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 = cloud_tpu.ListRuntimeVersionsRequest(request) diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc.py b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc.py index fd9f0f854c8d..dc4cebdab2a1 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/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.tpu_v2alpha1.types import cloud_tpu from .base import DEFAULT_CLIENT_INFO, TpuTransport +try: + from google.api_core import client_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.tpu.v2alpha1.Tpu", + "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.tpu.v2alpha1.Tpu", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TpuGrpcTransport(TpuTransport): """gRPC backend transport for Tpu. @@ -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 @@ -272,7 +360,7 @@ def list_nodes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_nodes" not in self._stubs: - self._stubs["list_nodes"] = self.grpc_channel.unary_unary( + self._stubs["list_nodes"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/ListNodes", request_serializer=cloud_tpu.ListNodesRequest.serialize, response_deserializer=cloud_tpu.ListNodesResponse.deserialize, @@ -296,7 +384,7 @@ def get_node(self) -> Callable[[cloud_tpu.GetNodeRequest], cloud_tpu.Node]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_node" not in self._stubs: - self._stubs["get_node"] = self.grpc_channel.unary_unary( + self._stubs["get_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/GetNode", request_serializer=cloud_tpu.GetNodeRequest.serialize, response_deserializer=cloud_tpu.Node.deserialize, @@ -322,7 +410,7 @@ def create_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_node" not in self._stubs: - self._stubs["create_node"] = self.grpc_channel.unary_unary( + self._stubs["create_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/CreateNode", request_serializer=cloud_tpu.CreateNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -348,7 +436,7 @@ def delete_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_node" not in self._stubs: - self._stubs["delete_node"] = self.grpc_channel.unary_unary( + self._stubs["delete_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/DeleteNode", request_serializer=cloud_tpu.DeleteNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -375,7 +463,7 @@ def stop_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_node" not in self._stubs: - self._stubs["stop_node"] = self.grpc_channel.unary_unary( + self._stubs["stop_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/StopNode", request_serializer=cloud_tpu.StopNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -401,7 +489,7 @@ def start_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_node" not in self._stubs: - self._stubs["start_node"] = self.grpc_channel.unary_unary( + self._stubs["start_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/StartNode", request_serializer=cloud_tpu.StartNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -427,7 +515,7 @@ def update_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_node" not in self._stubs: - self._stubs["update_node"] = self.grpc_channel.unary_unary( + self._stubs["update_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/UpdateNode", request_serializer=cloud_tpu.UpdateNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -455,7 +543,7 @@ def list_queued_resources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_queued_resources" not in self._stubs: - self._stubs["list_queued_resources"] = self.grpc_channel.unary_unary( + self._stubs["list_queued_resources"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/ListQueuedResources", request_serializer=cloud_tpu.ListQueuedResourcesRequest.serialize, response_deserializer=cloud_tpu.ListQueuedResourcesResponse.deserialize, @@ -481,7 +569,7 @@ def get_queued_resource( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_queued_resource" not in self._stubs: - self._stubs["get_queued_resource"] = self.grpc_channel.unary_unary( + self._stubs["get_queued_resource"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/GetQueuedResource", request_serializer=cloud_tpu.GetQueuedResourceRequest.serialize, response_deserializer=cloud_tpu.QueuedResource.deserialize, @@ -507,7 +595,7 @@ def create_queued_resource( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_queued_resource" not in self._stubs: - self._stubs["create_queued_resource"] = self.grpc_channel.unary_unary( + self._stubs["create_queued_resource"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/CreateQueuedResource", request_serializer=cloud_tpu.CreateQueuedResourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -533,7 +621,7 @@ def delete_queued_resource( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_queued_resource" not in self._stubs: - self._stubs["delete_queued_resource"] = self.grpc_channel.unary_unary( + self._stubs["delete_queued_resource"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/DeleteQueuedResource", request_serializer=cloud_tpu.DeleteQueuedResourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -559,7 +647,7 @@ def reset_queued_resource( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reset_queued_resource" not in self._stubs: - self._stubs["reset_queued_resource"] = self.grpc_channel.unary_unary( + self._stubs["reset_queued_resource"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/ResetQueuedResource", request_serializer=cloud_tpu.ResetQueuedResourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -589,7 +677,7 @@ def generate_service_identity( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_service_identity" not in self._stubs: - self._stubs["generate_service_identity"] = self.grpc_channel.unary_unary( + self._stubs["generate_service_identity"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/GenerateServiceIdentity", request_serializer=cloud_tpu.GenerateServiceIdentityRequest.serialize, response_deserializer=cloud_tpu.GenerateServiceIdentityResponse.deserialize, @@ -617,7 +705,7 @@ def list_accelerator_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_accelerator_types" not in self._stubs: - self._stubs["list_accelerator_types"] = self.grpc_channel.unary_unary( + self._stubs["list_accelerator_types"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/ListAcceleratorTypes", request_serializer=cloud_tpu.ListAcceleratorTypesRequest.serialize, response_deserializer=cloud_tpu.ListAcceleratorTypesResponse.deserialize, @@ -643,7 +731,7 @@ def get_accelerator_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_accelerator_type" not in self._stubs: - self._stubs["get_accelerator_type"] = self.grpc_channel.unary_unary( + self._stubs["get_accelerator_type"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/GetAcceleratorType", request_serializer=cloud_tpu.GetAcceleratorTypeRequest.serialize, response_deserializer=cloud_tpu.AcceleratorType.deserialize, @@ -671,7 +759,7 @@ def list_runtime_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_runtime_versions" not in self._stubs: - self._stubs["list_runtime_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_runtime_versions"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/ListRuntimeVersions", request_serializer=cloud_tpu.ListRuntimeVersionsRequest.serialize, response_deserializer=cloud_tpu.ListRuntimeVersionsResponse.deserialize, @@ -697,7 +785,7 @@ def get_runtime_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_runtime_version" not in self._stubs: - self._stubs["get_runtime_version"] = self.grpc_channel.unary_unary( + self._stubs["get_runtime_version"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/GetRuntimeVersion", request_serializer=cloud_tpu.GetRuntimeVersionRequest.serialize, response_deserializer=cloud_tpu.RuntimeVersion.deserialize, @@ -725,7 +813,7 @@ def get_guest_attributes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_guest_attributes" not in self._stubs: - self._stubs["get_guest_attributes"] = self.grpc_channel.unary_unary( + self._stubs["get_guest_attributes"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/GetGuestAttributes", request_serializer=cloud_tpu.GetGuestAttributesRequest.serialize, response_deserializer=cloud_tpu.GetGuestAttributesResponse.deserialize, @@ -753,7 +841,9 @@ def simulate_maintenance_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "simulate_maintenance_event" not in self._stubs: - self._stubs["simulate_maintenance_event"] = self.grpc_channel.unary_unary( + self._stubs[ + "simulate_maintenance_event" + ] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/SimulateMaintenanceEvent", request_serializer=cloud_tpu.SimulateMaintenanceEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -761,7 +851,7 @@ def simulate_maintenance_event( return self._stubs["simulate_maintenance_event"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -773,7 +863,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, @@ -790,7 +880,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, @@ -807,7 +897,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, @@ -826,7 +916,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, @@ -845,7 +935,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, @@ -862,7 +952,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-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc_asyncio.py b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc_asyncio.py index bbe88dcfc3f7..400b04a64928 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc_asyncio.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/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.tpu_v2alpha1.types import cloud_tpu from .base import DEFAULT_CLIENT_INFO, TpuTransport from .grpc import TpuGrpcTransport +try: + from google.api_core import client_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.tpu.v2alpha1.Tpu", + "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.tpu.v2alpha1.Tpu", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TpuGrpcAsyncIOTransport(TpuTransport): """gRPC AsyncIO backend transport for Tpu. @@ -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. @@ -282,7 +367,7 @@ def list_nodes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_nodes" not in self._stubs: - self._stubs["list_nodes"] = self.grpc_channel.unary_unary( + self._stubs["list_nodes"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/ListNodes", request_serializer=cloud_tpu.ListNodesRequest.serialize, response_deserializer=cloud_tpu.ListNodesResponse.deserialize, @@ -308,7 +393,7 @@ def get_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_node" not in self._stubs: - self._stubs["get_node"] = self.grpc_channel.unary_unary( + self._stubs["get_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/GetNode", request_serializer=cloud_tpu.GetNodeRequest.serialize, response_deserializer=cloud_tpu.Node.deserialize, @@ -334,7 +419,7 @@ def create_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_node" not in self._stubs: - self._stubs["create_node"] = self.grpc_channel.unary_unary( + self._stubs["create_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/CreateNode", request_serializer=cloud_tpu.CreateNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -360,7 +445,7 @@ def delete_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_node" not in self._stubs: - self._stubs["delete_node"] = self.grpc_channel.unary_unary( + self._stubs["delete_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/DeleteNode", request_serializer=cloud_tpu.DeleteNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -387,7 +472,7 @@ def stop_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_node" not in self._stubs: - self._stubs["stop_node"] = self.grpc_channel.unary_unary( + self._stubs["stop_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/StopNode", request_serializer=cloud_tpu.StopNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -413,7 +498,7 @@ def start_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_node" not in self._stubs: - self._stubs["start_node"] = self.grpc_channel.unary_unary( + self._stubs["start_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/StartNode", request_serializer=cloud_tpu.StartNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -439,7 +524,7 @@ def update_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_node" not in self._stubs: - self._stubs["update_node"] = self.grpc_channel.unary_unary( + self._stubs["update_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/UpdateNode", request_serializer=cloud_tpu.UpdateNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -468,7 +553,7 @@ def list_queued_resources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_queued_resources" not in self._stubs: - self._stubs["list_queued_resources"] = self.grpc_channel.unary_unary( + self._stubs["list_queued_resources"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/ListQueuedResources", request_serializer=cloud_tpu.ListQueuedResourcesRequest.serialize, response_deserializer=cloud_tpu.ListQueuedResourcesResponse.deserialize, @@ -496,7 +581,7 @@ def get_queued_resource( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_queued_resource" not in self._stubs: - self._stubs["get_queued_resource"] = self.grpc_channel.unary_unary( + self._stubs["get_queued_resource"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/GetQueuedResource", request_serializer=cloud_tpu.GetQueuedResourceRequest.serialize, response_deserializer=cloud_tpu.QueuedResource.deserialize, @@ -524,7 +609,7 @@ def create_queued_resource( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_queued_resource" not in self._stubs: - self._stubs["create_queued_resource"] = self.grpc_channel.unary_unary( + self._stubs["create_queued_resource"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/CreateQueuedResource", request_serializer=cloud_tpu.CreateQueuedResourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -552,7 +637,7 @@ def delete_queued_resource( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_queued_resource" not in self._stubs: - self._stubs["delete_queued_resource"] = self.grpc_channel.unary_unary( + self._stubs["delete_queued_resource"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/DeleteQueuedResource", request_serializer=cloud_tpu.DeleteQueuedResourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -580,7 +665,7 @@ def reset_queued_resource( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reset_queued_resource" not in self._stubs: - self._stubs["reset_queued_resource"] = self.grpc_channel.unary_unary( + self._stubs["reset_queued_resource"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/ResetQueuedResource", request_serializer=cloud_tpu.ResetQueuedResourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -610,7 +695,7 @@ def generate_service_identity( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_service_identity" not in self._stubs: - self._stubs["generate_service_identity"] = self.grpc_channel.unary_unary( + self._stubs["generate_service_identity"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/GenerateServiceIdentity", request_serializer=cloud_tpu.GenerateServiceIdentityRequest.serialize, response_deserializer=cloud_tpu.GenerateServiceIdentityResponse.deserialize, @@ -639,7 +724,7 @@ def list_accelerator_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_accelerator_types" not in self._stubs: - self._stubs["list_accelerator_types"] = self.grpc_channel.unary_unary( + self._stubs["list_accelerator_types"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/ListAcceleratorTypes", request_serializer=cloud_tpu.ListAcceleratorTypesRequest.serialize, response_deserializer=cloud_tpu.ListAcceleratorTypesResponse.deserialize, @@ -667,7 +752,7 @@ def get_accelerator_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_accelerator_type" not in self._stubs: - self._stubs["get_accelerator_type"] = self.grpc_channel.unary_unary( + self._stubs["get_accelerator_type"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/GetAcceleratorType", request_serializer=cloud_tpu.GetAcceleratorTypeRequest.serialize, response_deserializer=cloud_tpu.AcceleratorType.deserialize, @@ -696,7 +781,7 @@ def list_runtime_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_runtime_versions" not in self._stubs: - self._stubs["list_runtime_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_runtime_versions"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/ListRuntimeVersions", request_serializer=cloud_tpu.ListRuntimeVersionsRequest.serialize, response_deserializer=cloud_tpu.ListRuntimeVersionsResponse.deserialize, @@ -724,7 +809,7 @@ def get_runtime_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_runtime_version" not in self._stubs: - self._stubs["get_runtime_version"] = self.grpc_channel.unary_unary( + self._stubs["get_runtime_version"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/GetRuntimeVersion", request_serializer=cloud_tpu.GetRuntimeVersionRequest.serialize, response_deserializer=cloud_tpu.RuntimeVersion.deserialize, @@ -753,7 +838,7 @@ def get_guest_attributes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_guest_attributes" not in self._stubs: - self._stubs["get_guest_attributes"] = self.grpc_channel.unary_unary( + self._stubs["get_guest_attributes"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/GetGuestAttributes", request_serializer=cloud_tpu.GetGuestAttributesRequest.serialize, response_deserializer=cloud_tpu.GetGuestAttributesResponse.deserialize, @@ -781,7 +866,9 @@ def simulate_maintenance_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "simulate_maintenance_event" not in self._stubs: - self._stubs["simulate_maintenance_event"] = self.grpc_channel.unary_unary( + self._stubs[ + "simulate_maintenance_event" + ] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/SimulateMaintenanceEvent", request_serializer=cloud_tpu.SimulateMaintenanceEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -924,7 +1011,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: @@ -940,7 +1027,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, @@ -957,7 +1044,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, @@ -974,7 +1061,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, @@ -993,7 +1080,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, @@ -1012,7 +1099,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, @@ -1029,7 +1116,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-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v1.json b/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v1.json index 91c5476e75e7..0c1dfa7ef851 100644 --- a/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v1.json +++ b/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-tpu", - "version": "1.19.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", @@ -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.tpu_v1.types.AcceleratorType", @@ -465,7 +465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v1.types.AcceleratorType", @@ -546,7 +546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v1.types.Node", @@ -626,7 +626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v1.types.Node", @@ -707,7 +707,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v1.types.TensorFlowVersion", @@ -787,7 +787,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v1.types.TensorFlowVersion", @@ -868,7 +868,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v1.services.tpu.pagers.ListAcceleratorTypesAsyncPager", @@ -948,7 +948,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v1.services.tpu.pagers.ListAcceleratorTypesPager", @@ -1029,7 +1029,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v1.services.tpu.pagers.ListNodesAsyncPager", @@ -1109,7 +1109,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v1.services.tpu.pagers.ListNodesPager", @@ -1190,7 +1190,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v1.services.tpu.pagers.ListTensorFlowVersionsAsyncPager", @@ -1270,7 +1270,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v1.services.tpu.pagers.ListTensorFlowVersionsPager", @@ -1347,7 +1347,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1423,7 +1423,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1500,7 +1500,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1576,7 +1576,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1653,7 +1653,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1729,7 +1729,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-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2.json b/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2.json index 6087881385a7..f887178885e7 100644 --- a/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2.json +++ b/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-tpu", - "version": "1.19.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", @@ -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.cloud.tpu_v2.types.GenerateServiceIdentityResponse", @@ -457,7 +457,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.types.GenerateServiceIdentityResponse", @@ -538,7 +538,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.types.AcceleratorType", @@ -618,7 +618,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.types.AcceleratorType", @@ -695,7 +695,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.types.GetGuestAttributesResponse", @@ -771,7 +771,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.types.GetGuestAttributesResponse", @@ -852,7 +852,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.types.Node", @@ -932,7 +932,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.types.Node", @@ -1013,7 +1013,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.types.RuntimeVersion", @@ -1093,7 +1093,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.types.RuntimeVersion", @@ -1174,7 +1174,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.services.tpu.pagers.ListAcceleratorTypesAsyncPager", @@ -1254,7 +1254,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.services.tpu.pagers.ListAcceleratorTypesPager", @@ -1335,7 +1335,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.services.tpu.pagers.ListNodesAsyncPager", @@ -1415,7 +1415,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.services.tpu.pagers.ListNodesPager", @@ -1496,7 +1496,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.services.tpu.pagers.ListRuntimeVersionsAsyncPager", @@ -1576,7 +1576,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.services.tpu.pagers.ListRuntimeVersionsPager", @@ -1653,7 +1653,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1729,7 +1729,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1806,7 +1806,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1882,7 +1882,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1967,7 +1967,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2051,7 +2051,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-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2alpha1.json b/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2alpha1.json index fb9e919e65c6..5b36366634f6 100644 --- a/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2alpha1.json +++ b/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2alpha1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-tpu", - "version": "1.19.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", @@ -719,7 +719,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.types.GenerateServiceIdentityResponse", @@ -795,7 +795,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.types.GenerateServiceIdentityResponse", @@ -876,7 +876,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.types.AcceleratorType", @@ -956,7 +956,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.types.AcceleratorType", @@ -1033,7 +1033,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.types.GetGuestAttributesResponse", @@ -1109,7 +1109,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.types.GetGuestAttributesResponse", @@ -1190,7 +1190,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.types.Node", @@ -1270,7 +1270,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.types.Node", @@ -1351,7 +1351,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.types.QueuedResource", @@ -1431,7 +1431,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.types.QueuedResource", @@ -1512,7 +1512,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.types.RuntimeVersion", @@ -1592,7 +1592,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.types.RuntimeVersion", @@ -1673,7 +1673,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.services.tpu.pagers.ListAcceleratorTypesAsyncPager", @@ -1753,7 +1753,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.services.tpu.pagers.ListAcceleratorTypesPager", @@ -1834,7 +1834,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.services.tpu.pagers.ListNodesAsyncPager", @@ -1914,7 +1914,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.services.tpu.pagers.ListNodesPager", @@ -1995,7 +1995,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.services.tpu.pagers.ListQueuedResourcesAsyncPager", @@ -2075,7 +2075,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.services.tpu.pagers.ListQueuedResourcesPager", @@ -2156,7 +2156,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.services.tpu.pagers.ListRuntimeVersionsAsyncPager", @@ -2236,7 +2236,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.services.tpu.pagers.ListRuntimeVersionsPager", @@ -2317,7 +2317,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2397,7 +2397,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2474,7 +2474,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2550,7 +2550,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2627,7 +2627,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2703,7 +2703,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2780,7 +2780,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2856,7 +2856,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2941,7 +2941,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3025,7 +3025,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-tpu/tests/unit/gapic/tpu_v2/test_tpu.py b/packages/google-cloud-tpu/tests/unit/gapic/tpu_v2/test_tpu.py index d7c7d4977604..f46c89530ed1 100644 --- a/packages/google-cloud-tpu/tests/unit/gapic/tpu_v2/test_tpu.py +++ b/packages/google-cloud-tpu/tests/unit/gapic/tpu_v2/test_tpu.py @@ -5765,6 +5765,7 @@ def test_list_nodes_rest_required_fields(request_type=cloud_tpu.ListNodesRequest response_value._content = json_return_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) @@ -5818,6 +5819,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) @@ -6007,6 +6009,7 @@ def test_get_node_rest_required_fields(request_type=cloud_tpu.GetNodeRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_node(request) @@ -6052,6 +6055,7 @@ def test_get_node_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_node(**mock_args) @@ -6184,6 +6188,7 @@ def test_create_node_rest_required_fields(request_type=cloud_tpu.CreateNodeReque response_value._content = json_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_node(request) @@ -6237,6 +6242,7 @@ def test_create_node_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_node(**mock_args) @@ -6368,6 +6374,7 @@ def test_delete_node_rest_required_fields(request_type=cloud_tpu.DeleteNodeReque response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_node(request) @@ -6411,6 +6418,7 @@ def test_delete_node_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_node(**mock_args) @@ -6541,6 +6549,7 @@ def test_stop_node_rest_required_fields(request_type=cloud_tpu.StopNodeRequest): response_value._content = json_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_node(request) @@ -6660,6 +6669,7 @@ def test_start_node_rest_required_fields(request_type=cloud_tpu.StartNodeRequest response_value._content = json_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_node(request) @@ -6776,6 +6786,7 @@ def test_update_node_rest_required_fields(request_type=cloud_tpu.UpdateNodeReque response_value._content = json_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_node(request) @@ -6830,6 +6841,7 @@ def test_update_node_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_node(**mock_args) @@ -6967,6 +6979,7 @@ def test_generate_service_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.generate_service_identity(request) @@ -7100,6 +7113,7 @@ def test_list_accelerator_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_accelerator_types(request) @@ -7155,6 +7169,7 @@ def test_list_accelerator_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_accelerator_types(**mock_args) @@ -7353,6 +7368,7 @@ def test_get_accelerator_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_accelerator_type(request) @@ -7400,6 +7416,7 @@ def test_get_accelerator_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_accelerator_type(**mock_args) @@ -7545,6 +7562,7 @@ def test_list_runtime_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_runtime_versions(request) @@ -7600,6 +7618,7 @@ def test_list_runtime_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_runtime_versions(**mock_args) @@ -7798,6 +7817,7 @@ def test_get_runtime_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_runtime_version(request) @@ -7845,6 +7865,7 @@ def test_get_runtime_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_runtime_version(**mock_args) @@ -7981,6 +8002,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) @@ -8795,6 +8817,7 @@ def test_list_nodes_rest_bad_request(request_type=cloud_tpu.ListNodesRequest): response_value.status_code = 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) @@ -8831,6 +8854,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. @@ -8868,6 +8892,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 = cloud_tpu.ListNodesResponse.to_json( cloud_tpu.ListNodesResponse() ) @@ -8912,6 +8937,7 @@ def test_get_node_rest_bad_request(request_type=cloud_tpu.GetNodeRequest): response_value.status_code = 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_node(request) @@ -8959,6 +8985,7 @@ def test_get_node_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_node(request) # Establish that the response is the type that we expect. @@ -9007,6 +9034,7 @@ def test_get_node_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = cloud_tpu.Node.to_json(cloud_tpu.Node()) req.return_value.content = return_value @@ -9049,6 +9077,7 @@ def test_create_node_rest_bad_request(request_type=cloud_tpu.CreateNodeRequest): response_value.status_code = 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_node(request) @@ -9193,6 +9222,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_node(request) # Establish that the response is the type that we expect. @@ -9230,6 +9260,7 @@ def test_create_node_rest_interceptors(null_interceptor): req.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 @@ -9272,6 +9303,7 @@ def test_delete_node_rest_bad_request(request_type=cloud_tpu.DeleteNodeRequest): response_value.status_code = 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_node(request) @@ -9302,6 +9334,7 @@ def test_delete_node_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_node(request) # Establish that the response is the type that we expect. @@ -9339,6 +9372,7 @@ def test_delete_node_rest_interceptors(null_interceptor): req.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 @@ -9381,6 +9415,7 @@ def test_stop_node_rest_bad_request(request_type=cloud_tpu.StopNodeRequest): response_value.status_code = 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_node(request) @@ -9411,6 +9446,7 @@ def test_stop_node_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_node(request) # Establish that the response is the type that we expect. @@ -9448,6 +9484,7 @@ def test_stop_node_rest_interceptors(null_interceptor): req.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 @@ -9490,6 +9527,7 @@ def test_start_node_rest_bad_request(request_type=cloud_tpu.StartNodeRequest): response_value.status_code = 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_node(request) @@ -9520,6 +9558,7 @@ def test_start_node_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_node(request) # Establish that the response is the type that we expect. @@ -9557,6 +9596,7 @@ def test_start_node_rest_interceptors(null_interceptor): req.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 @@ -9601,6 +9641,7 @@ def test_update_node_rest_bad_request(request_type=cloud_tpu.UpdateNodeRequest): response_value.status_code = 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_node(request) @@ -9747,6 +9788,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_node(request) # Establish that the response is the type that we expect. @@ -9784,6 +9826,7 @@ def test_update_node_rest_interceptors(null_interceptor): req.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 @@ -9828,6 +9871,7 @@ def test_generate_service_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.generate_service_identity(request) @@ -9861,6 +9905,7 @@ def test_generate_service_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.generate_service_identity(request) # Establish that the response is the type that we expect. @@ -9898,6 +9943,7 @@ def test_generate_service_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 = cloud_tpu.GenerateServiceIdentityResponse.to_json( cloud_tpu.GenerateServiceIdentityResponse() ) @@ -9944,6 +9990,7 @@ def test_list_accelerator_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_accelerator_types(request) @@ -9980,6 +10027,7 @@ def test_list_accelerator_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_accelerator_types(request) # Establish that the response is the type that we expect. @@ -10019,6 +10067,7 @@ def test_list_accelerator_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 = cloud_tpu.ListAcceleratorTypesResponse.to_json( cloud_tpu.ListAcceleratorTypesResponse() ) @@ -10067,6 +10116,7 @@ def test_get_accelerator_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_accelerator_type(request) @@ -10105,6 +10155,7 @@ def test_get_accelerator_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_accelerator_type(request) # Establish that the response is the type that we expect. @@ -10144,6 +10195,7 @@ def test_get_accelerator_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 = cloud_tpu.AcceleratorType.to_json(cloud_tpu.AcceleratorType()) req.return_value.content = return_value @@ -10188,6 +10240,7 @@ def test_list_runtime_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_runtime_versions(request) @@ -10224,6 +10277,7 @@ def test_list_runtime_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_runtime_versions(request) # Establish that the response is the type that we expect. @@ -10263,6 +10317,7 @@ def test_list_runtime_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 = cloud_tpu.ListRuntimeVersionsResponse.to_json( cloud_tpu.ListRuntimeVersionsResponse() ) @@ -10311,6 +10366,7 @@ def test_get_runtime_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_runtime_version(request) @@ -10349,6 +10405,7 @@ def test_get_runtime_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_runtime_version(request) # Establish that the response is the type that we expect. @@ -10388,6 +10445,7 @@ def test_get_runtime_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 = cloud_tpu.RuntimeVersion.to_json(cloud_tpu.RuntimeVersion()) req.return_value.content = return_value @@ -10432,6 +10490,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) @@ -10465,6 +10524,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. @@ -10502,6 +10562,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 = cloud_tpu.GetGuestAttributesResponse.to_json( cloud_tpu.GetGuestAttributesResponse() ) @@ -10548,6 +10609,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) @@ -10578,6 +10640,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) @@ -10606,6 +10669,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) @@ -10636,6 +10700,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) @@ -10666,6 +10731,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) @@ -10696,6 +10762,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) @@ -10726,6 +10793,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) @@ -10756,6 +10824,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) @@ -10786,6 +10855,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) @@ -10816,6 +10886,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) @@ -10846,6 +10917,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) @@ -10876,6 +10948,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-trace/google/cloud/trace/gapic_version.py b/packages/google-cloud-trace/google/cloud/trace/gapic_version.py index 231f5cf041ff..558c8aab67c5 100644 --- a/packages/google-cloud-trace/google/cloud/trace/gapic_version.py +++ b/packages/google-cloud-trace/google/cloud/trace/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.14.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-trace/google/cloud/trace_v1/gapic_version.py b/packages/google-cloud-trace/google/cloud/trace_v1/gapic_version.py index 231f5cf041ff..558c8aab67c5 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v1/gapic_version.py +++ b/packages/google-cloud-trace/google/cloud/trace_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.14.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/async_client.py b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/async_client.py index 6ed28847cbe8..31976891eef0 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/async_client.py +++ b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_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, TraceServiceTransport from .transports.grpc_asyncio import TraceServiceGrpcAsyncIOTransport +try: + from google.api_core import client_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 TraceServiceAsyncClient: """This file describes an API for collecting and viewing traces @@ -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.devtools.cloudtrace_v1.TraceServiceAsyncClient`.", + extra={ + "serviceName": "google.devtools.cloudtrace.v1.TraceService", + "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.devtools.cloudtrace.v1.TraceService", + "credentialsType": None, + }, + ) + async def list_traces( self, request: Optional[Union[trace.ListTracesRequest, dict]] = None, @@ -261,7 +293,7 @@ async def list_traces( project_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.ListTracesAsyncPager: r"""Returns of a list of traces that match the specified filter conditions. @@ -307,8 +339,10 @@ async def sample_list_traces(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.trace_v1.services.trace_service.pagers.ListTracesAsyncPager: @@ -385,7 +419,7 @@ async def get_trace( trace_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]]] = (), ) -> trace.Trace: r"""Gets a single trace by its ID. @@ -434,8 +468,10 @@ async def sample_get_trace(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.trace_v1.types.Trace: @@ -507,7 +543,7 @@ async def patch_traces( traces: Optional[trace.Traces] = None, retry: OptionalRetry = 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"""Sends new traces to Stackdriver Trace or updates existing traces. If the ID of a trace that you send @@ -558,8 +594,10 @@ async def sample_patch_traces(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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-cloud-trace/google/cloud/trace_v1/services/trace_service/client.py b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/client.py index 88b9461c2edb..41d1ed054d6a 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/client.py +++ b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_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.cloud.trace_v1.services.trace_service import pagers from google.cloud.trace_v1.types import trace @@ -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( @@ -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.devtools.cloudtrace_v1.TraceServiceClient`.", + extra={ + "serviceName": "google.devtools.cloudtrace.v1.TraceService", + "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.devtools.cloudtrace.v1.TraceService", + "credentialsType": None, + }, + ) + def list_traces( self, request: Optional[Union[trace.ListTracesRequest, dict]] = None, @@ -629,7 +666,7 @@ def list_traces( project_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.ListTracesPager: r"""Returns of a list of traces that match the specified filter conditions. @@ -675,8 +712,10 @@ def sample_list_traces(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.trace_v1.services.trace_service.pagers.ListTracesPager: @@ -750,7 +789,7 @@ def get_trace( trace_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]]] = (), ) -> trace.Trace: r"""Gets a single trace by its ID. @@ -799,8 +838,10 @@ def sample_get_trace(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.trace_v1.types.Trace: @@ -869,7 +910,7 @@ def patch_traces( traces: Optional[trace.Traces] = None, retry: OptionalRetry = 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"""Sends new traces to Stackdriver Trace or updates existing traces. If the ID of a trace that you send @@ -920,8 +961,10 @@ def sample_patch_traces(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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-cloud-trace/google/cloud/trace_v1/services/trace_service/pagers.py b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/pagers.py index 7713f73b2374..fcc3ddb83eb9 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/pagers.py +++ b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_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 = trace.ListTracesRequest(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 = trace.ListTracesRequest(request) diff --git a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/grpc.py b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/grpc.py index 68bbf4c3d2ff..c500d6d69f80 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/grpc.py +++ b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_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.cloud.trace_v1.types import trace from .base import DEFAULT_CLIENT_INFO, TraceServiceTransport +try: + from google.api_core import client_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.devtools.cloudtrace.v1.TraceService", + "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.devtools.cloudtrace.v1.TraceService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TraceServiceGrpcTransport(TraceServiceTransport): """gRPC backend transport for TraceService. @@ -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 @@ -260,7 +346,7 @@ def list_traces( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_traces" not in self._stubs: - self._stubs["list_traces"] = self.grpc_channel.unary_unary( + self._stubs["list_traces"] = self._logged_channel.unary_unary( "/google.devtools.cloudtrace.v1.TraceService/ListTraces", request_serializer=trace.ListTracesRequest.serialize, response_deserializer=trace.ListTracesResponse.deserialize, @@ -284,7 +370,7 @@ def get_trace(self) -> Callable[[trace.GetTraceRequest], trace.Trace]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_trace" not in self._stubs: - self._stubs["get_trace"] = self.grpc_channel.unary_unary( + self._stubs["get_trace"] = self._logged_channel.unary_unary( "/google.devtools.cloudtrace.v1.TraceService/GetTrace", request_serializer=trace.GetTraceRequest.serialize, response_deserializer=trace.Trace.deserialize, @@ -314,7 +400,7 @@ def patch_traces(self) -> Callable[[trace.PatchTracesRequest], empty_pb2.Empty]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "patch_traces" not in self._stubs: - self._stubs["patch_traces"] = self.grpc_channel.unary_unary( + self._stubs["patch_traces"] = self._logged_channel.unary_unary( "/google.devtools.cloudtrace.v1.TraceService/PatchTraces", request_serializer=trace.PatchTracesRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -322,7 +408,7 @@ def patch_traces(self) -> Callable[[trace.PatchTracesRequest], empty_pb2.Empty]: return self._stubs["patch_traces"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/grpc_asyncio.py b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/grpc_asyncio.py index 5f1e5e1a17fb..1e7200ddebe6 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_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.cloud.trace_v1.types import trace from .base import DEFAULT_CLIENT_INFO, TraceServiceTransport from .grpc import TraceServiceGrpcTransport +try: + from google.api_core import client_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.devtools.cloudtrace.v1.TraceService", + "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.devtools.cloudtrace.v1.TraceService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TraceServiceGrpcAsyncIOTransport(TraceServiceTransport): """gRPC AsyncIO backend transport for TraceService. @@ -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 @@ -268,7 +353,7 @@ def list_traces( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_traces" not in self._stubs: - self._stubs["list_traces"] = self.grpc_channel.unary_unary( + self._stubs["list_traces"] = self._logged_channel.unary_unary( "/google.devtools.cloudtrace.v1.TraceService/ListTraces", request_serializer=trace.ListTracesRequest.serialize, response_deserializer=trace.ListTracesResponse.deserialize, @@ -292,7 +377,7 @@ def get_trace(self) -> Callable[[trace.GetTraceRequest], Awaitable[trace.Trace]] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_trace" not in self._stubs: - self._stubs["get_trace"] = self.grpc_channel.unary_unary( + self._stubs["get_trace"] = self._logged_channel.unary_unary( "/google.devtools.cloudtrace.v1.TraceService/GetTrace", request_serializer=trace.GetTraceRequest.serialize, response_deserializer=trace.Trace.deserialize, @@ -324,7 +409,7 @@ def patch_traces( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "patch_traces" not in self._stubs: - self._stubs["patch_traces"] = self.grpc_channel.unary_unary( + self._stubs["patch_traces"] = self._logged_channel.unary_unary( "/google.devtools.cloudtrace.v1.TraceService/PatchTraces", request_serializer=trace.PatchTracesRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -387,7 +472,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-trace/google/cloud/trace_v1/services/trace_service/transports/rest.py b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/rest.py index 2744481b0daf..aa9d715a6019 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/rest.py +++ b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_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, @@ -88,8 +96,10 @@ def pre_patch_traces(self, request, metadata): """ def pre_get_trace( - self, request: trace.GetTraceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[trace.GetTraceRequest, Sequence[Tuple[str, str]]]: + self, + request: trace.GetTraceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[trace.GetTraceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_trace Override in a subclass to manipulate the request or metadata @@ -107,8 +117,10 @@ def post_get_trace(self, response: trace.Trace) -> trace.Trace: return response def pre_list_traces( - self, request: trace.ListTracesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[trace.ListTracesRequest, Sequence[Tuple[str, str]]]: + self, + request: trace.ListTracesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[trace.ListTracesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_traces Override in a subclass to manipulate the request or metadata @@ -128,8 +140,10 @@ def post_list_traces( return response def pre_patch_traces( - self, request: trace.PatchTracesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[trace.PatchTracesRequest, Sequence[Tuple[str, str]]]: + self, + request: trace.PatchTracesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[trace.PatchTracesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for patch_traces Override in a subclass to manipulate the request or metadata @@ -261,7 +275,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> trace.Trace: r"""Call the get trace method over HTTP. @@ -271,8 +285,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.trace.Trace: @@ -287,6 +303,7 @@ def __call__( http_options = ( _BaseTraceServiceRestTransport._BaseGetTrace._get_http_options() ) + request, metadata = self._interceptor.pre_get_trace(request, metadata) transcoded_request = ( _BaseTraceServiceRestTransport._BaseGetTrace._get_transcoded_request( @@ -301,6 +318,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.devtools.cloudtrace_v1.TraceServiceClient.GetTrace", + extra={ + "serviceName": "google.devtools.cloudtrace.v1.TraceService", + "rpcName": "GetTrace", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TraceServiceRestTransport._GetTrace._get_response( self._host, @@ -321,7 +365,29 @@ def __call__( pb_resp = trace.Trace.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_trace(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = trace.Trace.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.cloudtrace_v1.TraceServiceClient.get_trace", + extra={ + "serviceName": "google.devtools.cloudtrace.v1.TraceService", + "rpcName": "GetTrace", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTraces( @@ -358,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]]] = (), ) -> trace.ListTracesResponse: r"""Call the list traces method over HTTP. @@ -369,8 +435,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.trace.ListTracesResponse: @@ -380,6 +448,7 @@ def __call__( http_options = ( _BaseTraceServiceRestTransport._BaseListTraces._get_http_options() ) + request, metadata = self._interceptor.pre_list_traces(request, metadata) transcoded_request = ( _BaseTraceServiceRestTransport._BaseListTraces._get_transcoded_request( @@ -394,6 +463,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.devtools.cloudtrace_v1.TraceServiceClient.ListTraces", + extra={ + "serviceName": "google.devtools.cloudtrace.v1.TraceService", + "rpcName": "ListTraces", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TraceServiceRestTransport._ListTraces._get_response( self._host, @@ -414,7 +510,29 @@ def __call__( pb_resp = trace.ListTracesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_traces(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = trace.ListTracesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.cloudtrace_v1.TraceServiceClient.list_traces", + extra={ + "serviceName": "google.devtools.cloudtrace.v1.TraceService", + "rpcName": "ListTraces", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PatchTraces( @@ -452,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]]] = (), ): r"""Call the patch traces method over HTTP. @@ -462,13 +580,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 = ( _BaseTraceServiceRestTransport._BasePatchTraces._get_http_options() ) + request, metadata = self._interceptor.pre_patch_traces(request, metadata) transcoded_request = ( _BaseTraceServiceRestTransport._BasePatchTraces._get_transcoded_request( @@ -489,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.devtools.cloudtrace_v1.TraceServiceClient.PatchTraces", + extra={ + "serviceName": "google.devtools.cloudtrace.v1.TraceService", + "rpcName": "PatchTraces", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TraceServiceRestTransport._PatchTraces._get_response( self._host, diff --git a/packages/google-cloud-trace/google/cloud/trace_v2/gapic_version.py b/packages/google-cloud-trace/google/cloud/trace_v2/gapic_version.py index 231f5cf041ff..558c8aab67c5 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v2/gapic_version.py +++ b/packages/google-cloud-trace/google/cloud/trace_v2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.14.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/async_client.py b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/async_client.py index 2eb82e7b7427..d398284fb2fd 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/async_client.py +++ b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_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, @@ -52,6 +53,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TraceServiceTransport from .transports.grpc_asyncio import TraceServiceGrpcAsyncIOTransport +try: + from google.api_core import client_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 TraceServiceAsyncClient: """Service for collecting and viewing traces and spans within a @@ -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.devtools.cloudtrace_v2.TraceServiceAsyncClient`.", + extra={ + "serviceName": "google.devtools.cloudtrace.v2.TraceService", + "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.devtools.cloudtrace.v2.TraceService", + "credentialsType": None, + }, + ) + async def batch_write_spans( self, request: Optional[Union[tracing.BatchWriteSpansRequest, dict]] = None, @@ -269,7 +301,7 @@ async def batch_write_spans( spans: Optional[MutableSequence[trace.Span]] = None, retry: OptionalRetry = 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"""Batch writes new spans to new or existing traces. You cannot update existing spans. @@ -324,8 +356,10 @@ async def sample_batch_write_spans(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -378,7 +412,7 @@ async def create_span( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> trace.Span: r"""Creates a new span. @@ -425,8 +459,10 @@ async def sample_create_span(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.trace_v2.types.Span: diff --git a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/client.py b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/client.py index 51b81b2f7017..06424cdf1fd6 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/client.py +++ b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_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.protobuf import wrappers_pb2 # type: ignore from google.rpc import status_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.devtools.cloudtrace_v2.TraceServiceClient`.", + extra={ + "serviceName": "google.devtools.cloudtrace.v2.TraceService", + "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.devtools.cloudtrace.v2.TraceService", + "credentialsType": None, + }, + ) + def batch_write_spans( self, request: Optional[Union[tracing.BatchWriteSpansRequest, dict]] = None, @@ -657,7 +694,7 @@ def batch_write_spans( spans: Optional[MutableSequence[trace.Span]] = None, retry: OptionalRetry = 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"""Batch writes new spans to new or existing traces. You cannot update existing spans. @@ -712,8 +749,10 @@ def sample_batch_write_spans(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -763,7 +802,7 @@ def create_span( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> trace.Span: r"""Creates a new span. @@ -810,8 +849,10 @@ def sample_create_span(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.trace_v2.types.Span: diff --git a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/grpc.py b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/grpc.py index ea932ffe20b3..6a41fb389670 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/grpc.py +++ b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_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.cloud.trace_v2.types import trace, tracing from .base import DEFAULT_CLIENT_INFO, TraceServiceTransport +try: + from google.api_core import client_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.devtools.cloudtrace.v2.TraceService", + "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.devtools.cloudtrace.v2.TraceService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TraceServiceGrpcTransport(TraceServiceTransport): """gRPC backend transport for TraceService. @@ -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 @@ -262,7 +348,7 @@ def batch_write_spans( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_write_spans" not in self._stubs: - self._stubs["batch_write_spans"] = self.grpc_channel.unary_unary( + self._stubs["batch_write_spans"] = self._logged_channel.unary_unary( "/google.devtools.cloudtrace.v2.TraceService/BatchWriteSpans", request_serializer=tracing.BatchWriteSpansRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -286,7 +372,7 @@ def create_span(self) -> Callable[[trace.Span], trace.Span]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_span" not in self._stubs: - self._stubs["create_span"] = self.grpc_channel.unary_unary( + self._stubs["create_span"] = self._logged_channel.unary_unary( "/google.devtools.cloudtrace.v2.TraceService/CreateSpan", request_serializer=trace.Span.serialize, response_deserializer=trace.Span.deserialize, @@ -294,7 +380,7 @@ def create_span(self) -> Callable[[trace.Span], trace.Span]: return self._stubs["create_span"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/grpc_asyncio.py b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/grpc_asyncio.py index 492d02f2b9f0..deafca3ddf29 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_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.cloud.trace_v2.types import trace, tracing from .base import DEFAULT_CLIENT_INFO, TraceServiceTransport from .grpc import TraceServiceGrpcTransport +try: + from google.api_core import client_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.devtools.cloudtrace.v2.TraceService", + "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.devtools.cloudtrace.v2.TraceService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TraceServiceGrpcAsyncIOTransport(TraceServiceTransport): """gRPC AsyncIO backend transport for TraceService. @@ -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 @@ -270,7 +355,7 @@ def batch_write_spans( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_write_spans" not in self._stubs: - self._stubs["batch_write_spans"] = self.grpc_channel.unary_unary( + self._stubs["batch_write_spans"] = self._logged_channel.unary_unary( "/google.devtools.cloudtrace.v2.TraceService/BatchWriteSpans", request_serializer=tracing.BatchWriteSpansRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -294,7 +379,7 @@ def create_span(self) -> Callable[[trace.Span], Awaitable[trace.Span]]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_span" not in self._stubs: - self._stubs["create_span"] = self.grpc_channel.unary_unary( + self._stubs["create_span"] = self._logged_channel.unary_unary( "/google.devtools.cloudtrace.v2.TraceService/CreateSpan", request_serializer=trace.Span.serialize, response_deserializer=trace.Span.deserialize, @@ -342,7 +427,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-trace/google/cloud/trace_v2/services/trace_service/transports/rest.py b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/rest.py index 898fa25a0814..7bf5d092ee99 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/rest.py +++ b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_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,8 @@ def post_create_span(self, response): def pre_batch_write_spans( self, request: tracing.BatchWriteSpansRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tracing.BatchWriteSpansRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tracing.BatchWriteSpansRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for batch_write_spans Override in a subclass to manipulate the request or metadata @@ -92,8 +100,8 @@ def pre_batch_write_spans( return request, metadata def pre_create_span( - self, request: trace.Span, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[trace.Span, Sequence[Tuple[str, str]]]: + self, request: trace.Span, metadata: Sequence[Tuple[str, Union[str, bytes]]] + ) -> Tuple[trace.Span, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_span Override in a subclass to manipulate the request or metadata @@ -239,7 +247,7 @@ 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 batch write spans method over HTTP. @@ -249,13 +257,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 = ( _BaseTraceServiceRestTransport._BaseBatchWriteSpans._get_http_options() ) + request, metadata = self._interceptor.pre_batch_write_spans( request, metadata ) @@ -272,6 +283,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.devtools.cloudtrace_v2.TraceServiceClient.BatchWriteSpans", + extra={ + "serviceName": "google.devtools.cloudtrace.v2.TraceService", + "rpcName": "BatchWriteSpans", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TraceServiceRestTransport._BatchWriteSpans._get_response( self._host, @@ -323,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]]] = (), ) -> trace.Span: r"""Call the create span method over HTTP. @@ -343,8 +381,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.trace.Span: @@ -365,6 +405,7 @@ def __call__( http_options = ( _BaseTraceServiceRestTransport._BaseCreateSpan._get_http_options() ) + request, metadata = self._interceptor.pre_create_span(request, metadata) transcoded_request = ( _BaseTraceServiceRestTransport._BaseCreateSpan._get_transcoded_request( @@ -385,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.devtools.cloudtrace_v2.TraceServiceClient.CreateSpan", + extra={ + "serviceName": "google.devtools.cloudtrace.v2.TraceService", + "rpcName": "CreateSpan", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TraceServiceRestTransport._CreateSpan._get_response( self._host, @@ -406,7 +474,29 @@ def __call__( pb_resp = trace.Span.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_span(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = trace.Span.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.cloudtrace_v2.TraceServiceClient.create_span", + extra={ + "serviceName": "google.devtools.cloudtrace.v2.TraceService", + "rpcName": "CreateSpan", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-trace/samples/generated_samples/snippet_metadata_google.devtools.cloudtrace.v1.json b/packages/google-cloud-trace/samples/generated_samples/snippet_metadata_google.devtools.cloudtrace.v1.json index 7c1dfd761136..a4f20614ce5b 100644 --- a/packages/google-cloud-trace/samples/generated_samples/snippet_metadata_google.devtools.cloudtrace.v1.json +++ b/packages/google-cloud-trace/samples/generated_samples/snippet_metadata_google.devtools.cloudtrace.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-trace", - "version": "1.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.trace_v1.types.Trace", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.trace_v1.types.Trace", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.trace_v1.services.trace_service.pagers.ListTracesAsyncPager", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.trace_v1.services.trace_service.pagers.ListTracesPager", @@ -381,7 +381,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "patch_traces" @@ -462,7 +462,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "patch_traces" diff --git a/packages/google-cloud-trace/samples/generated_samples/snippet_metadata_google.devtools.cloudtrace.v2.json b/packages/google-cloud-trace/samples/generated_samples/snippet_metadata_google.devtools.cloudtrace.v2.json index 6b5b5d92f372..b7d6fcf9f839 100644 --- a/packages/google-cloud-trace/samples/generated_samples/snippet_metadata_google.devtools.cloudtrace.v2.json +++ b/packages/google-cloud-trace/samples/generated_samples/snippet_metadata_google.devtools.cloudtrace.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-trace", - "version": "1.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]]]" } ], "shortName": "batch_write_spans" @@ -132,7 +132,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "batch_write_spans" @@ -206,7 +206,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.trace_v2.types.Span", @@ -282,7 +282,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.trace_v2.types.Span", diff --git a/packages/google-cloud-trace/tests/unit/gapic/trace_v1/test_trace_service.py b/packages/google-cloud-trace/tests/unit/gapic/trace_v1/test_trace_service.py index f408bb6c6666..0edd38cff7b2 100644 --- a/packages/google-cloud-trace/tests/unit/gapic/trace_v1/test_trace_service.py +++ b/packages/google-cloud-trace/tests/unit/gapic/trace_v1/test_trace_service.py @@ -2333,6 +2333,7 @@ def test_list_traces_rest_required_fields(request_type=trace.ListTracesRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_traces(request) @@ -2391,6 +2392,7 @@ def test_list_traces_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_traces(**mock_args) @@ -2583,6 +2585,7 @@ def test_get_trace_rest_required_fields(request_type=trace.GetTraceRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_trace(request) @@ -2637,6 +2640,7 @@ def test_get_trace_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_trace(**mock_args) @@ -2764,6 +2768,7 @@ def test_patch_traces_rest_required_fields(request_type=trace.PatchTracesRequest response_value._content = json_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_traces(request) @@ -2816,6 +2821,7 @@ def test_patch_traces_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.patch_traces(**mock_args) @@ -3131,6 +3137,7 @@ def test_list_traces_rest_bad_request(request_type=trace.ListTracesRequest): response_value.status_code = 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_traces(request) @@ -3166,6 +3173,7 @@ def test_list_traces_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_traces(request) # Establish that the response is the type that we expect. @@ -3204,6 +3212,7 @@ def test_list_traces_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = trace.ListTracesResponse.to_json(trace.ListTracesResponse()) req.return_value.content = return_value @@ -3246,6 +3255,7 @@ def test_get_trace_rest_bad_request(request_type=trace.GetTraceRequest): response_value.status_code = 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_trace(request) @@ -3282,6 +3292,7 @@ def test_get_trace_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_trace(request) # Establish that the response is the type that we expect. @@ -3321,6 +3332,7 @@ def test_get_trace_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = trace.Trace.to_json(trace.Trace()) req.return_value.content = return_value @@ -3363,6 +3375,7 @@ def test_patch_traces_rest_bad_request(request_type=trace.PatchTracesRequest): response_value.status_code = 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_traces(request) @@ -3479,6 +3492,7 @@ def get_message_fields(field): 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.patch_traces(request) # Establish that the response is the type that we expect. @@ -3513,6 +3527,7 @@ def test_patch_traces_rest_interceptors(null_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 = trace.PatchTracesRequest() metadata = [ diff --git a/packages/google-cloud-trace/tests/unit/gapic/trace_v2/test_trace_service.py b/packages/google-cloud-trace/tests/unit/gapic/trace_v2/test_trace_service.py index 43f62175b138..58b8e3ab660b 100644 --- a/packages/google-cloud-trace/tests/unit/gapic/trace_v2/test_trace_service.py +++ b/packages/google-cloud-trace/tests/unit/gapic/trace_v2/test_trace_service.py @@ -1737,6 +1737,7 @@ def test_batch_write_spans_rest_required_fields( response_value._content = json_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_write_spans(request) @@ -1789,6 +1790,7 @@ def test_batch_write_spans_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.batch_write_spans(**mock_args) @@ -1923,6 +1925,7 @@ def test_create_span_rest_required_fields(request_type=trace.Span): response_value._content = json_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_span(request) @@ -2198,6 +2201,7 @@ def test_batch_write_spans_rest_bad_request( response_value.status_code = 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_write_spans(request) @@ -2228,6 +2232,7 @@ def test_batch_write_spans_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.batch_write_spans(request) # Establish that the response is the type that we expect. @@ -2262,6 +2267,7 @@ def test_batch_write_spans_rest_interceptors(null_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 = tracing.BatchWriteSpansRequest() metadata = [ @@ -2300,6 +2306,7 @@ def test_create_span_rest_bad_request(request_type=trace.Span): response_value.status_code = 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_span(request) @@ -2338,6 +2345,7 @@ def test_create_span_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_span(request) # Establish that the response is the type that we expect. @@ -2379,6 +2387,7 @@ def test_create_span_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = trace.Span.to_json(trace.Span()) req.return_value.content = return_value diff --git a/packages/google-cloud-translate/google/cloud/translate/gapic_version.py b/packages/google-cloud-translate/google/cloud/translate/gapic_version.py index 4138c894ea3a..558c8aab67c5 100644 --- a/packages/google-cloud-translate/google/cloud/translate/gapic_version.py +++ b/packages/google-cloud-translate/google/cloud/translate/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.18.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-translate/google/cloud/translate_v3/gapic_version.py b/packages/google-cloud-translate/google/cloud/translate_v3/gapic_version.py index 4138c894ea3a..558c8aab67c5 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3/gapic_version.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.18.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/async_client.py b/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/async_client.py index be93575f07a6..480dde1e4f0b 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/async_client.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_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, @@ -64,6 +65,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TranslationServiceTransport from .transports.grpc_asyncio import TranslationServiceGrpcAsyncIOTransport +try: + from google.api_core import client_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 TranslationServiceAsyncClient: """Provides natural language translation operations.""" @@ -299,6 +309,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.translation_v3.TranslationServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "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.translation.v3.TranslationService", + "credentialsType": None, + }, + ) + async def translate_text( self, request: Optional[Union[translation_service.TranslateTextRequest, dict]] = None, @@ -311,7 +343,7 @@ async def translate_text( source_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]]] = (), ) -> translation_service.TranslateTextResponse: r"""Translates input text and returns translated text. @@ -437,8 +469,10 @@ async def sample_translate_text(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.types.TranslateTextResponse: @@ -517,7 +551,7 @@ async def romanize_text( contents: 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]]] = (), ) -> translation_service.RomanizeTextResponse: r"""Romanize input text written in non-Latin scripts to Latin text. @@ -578,8 +612,10 @@ async def sample_romanize_text(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.types.RomanizeTextResponse: @@ -647,7 +683,7 @@ async def detect_language( content: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.DetectLanguageResponse: r"""Detects the language of text within a request. @@ -735,8 +771,10 @@ async def sample_detect_language(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.types.DetectLanguageResponse: @@ -807,7 +845,7 @@ async def get_supported_languages( display_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]]] = (), ) -> translation_service.SupportedLanguages: r"""Returns a list of supported languages for translation. @@ -893,8 +931,10 @@ async def sample_get_supported_languages(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.types.SupportedLanguages: @@ -960,7 +1000,7 @@ async def translate_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]]] = (), ) -> translation_service.TranslateDocumentResponse: r"""Translates documents in synchronous mode. @@ -1001,8 +1041,10 @@ async def sample_translate_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.translate_v3.types.TranslateDocumentResponse: @@ -1050,7 +1092,7 @@ async def batch_translate_text( *, retry: OptionalRetry = gapic_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"""Translates a large volume of text in asynchronous batch mode. This function provides real-time output as @@ -1109,8 +1151,10 @@ async def sample_batch_translate_text(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1177,7 +1221,7 @@ async def batch_translate_document( output_config: Optional[translation_service.BatchDocumentOutputConfig] = None, retry: OptionalRetry = gapic_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"""Translates a large volume of document in asynchronous batch mode. This function provides real-time output as @@ -1291,8 +1335,10 @@ async def sample_batch_translate_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: @@ -1384,7 +1430,7 @@ async def create_glossary( glossary: Optional[translation_service.Glossary] = None, retry: OptionalRetry = gapic_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 glossary and returns the long-running operation. Returns NOT_FOUND, if the project doesn't exist. @@ -1439,8 +1485,10 @@ async def sample_create_glossary(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1517,7 +1565,7 @@ async def update_glossary( 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 glossary. A LRO is used since the update can be async if the glossary's entry file is updated. @@ -1576,8 +1624,10 @@ async def sample_update_glossary(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1655,7 +1705,7 @@ async def list_glossaries( 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.ListGlossariesAsyncPager: r"""Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. @@ -1701,8 +1751,10 @@ async def sample_list_glossaries(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.services.translation_service.pagers.ListGlossariesAsyncPager: @@ -1777,7 +1829,7 @@ async def get_glossary( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.Glossary: r"""Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist. @@ -1821,8 +1873,10 @@ async def sample_get_glossary(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.types.Glossary: @@ -1885,7 +1939,7 @@ async def delete_glossary( name: Optional[str] = None, retry: OptionalRetry = gapic_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 glossary, or cancels glossary construction if the glossary isn't created yet. Returns NOT_FOUND, if the glossary @@ -1934,8 +1988,10 @@ async def sample_delete_glossary(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2009,7 +2065,7 @@ async def get_glossary_entry( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.GlossaryEntry: r"""Gets a single glossary entry by the given id. @@ -2053,8 +2109,10 @@ async def sample_get_glossary_entry(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.types.GlossaryEntry: @@ -2117,7 +2175,7 @@ async def list_glossary_entries( 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.ListGlossaryEntriesAsyncPager: r"""List the entries for the glossary. @@ -2163,8 +2221,10 @@ async def sample_list_glossary_entries(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.services.translation_service.pagers.ListGlossaryEntriesAsyncPager: @@ -2242,7 +2302,7 @@ async def create_glossary_entry( glossary_entry: Optional[common.GlossaryEntry] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.GlossaryEntry: r"""Creates a glossary entry. @@ -2293,8 +2353,10 @@ async def sample_create_glossary_entry(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.types.GlossaryEntry: @@ -2359,7 +2421,7 @@ async def update_glossary_entry( glossary_entry: Optional[common.GlossaryEntry] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.GlossaryEntry: r"""Updates a glossary entry. @@ -2402,8 +2464,10 @@ async def sample_update_glossary_entry(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.types.GlossaryEntry: @@ -2468,7 +2532,7 @@ async def delete_glossary_entry( name: Optional[str] = None, retry: OptionalRetry = 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 entry from the glossary @@ -2509,8 +2573,10 @@ async def sample_delete_glossary_entry(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -2563,7 +2629,7 @@ async def create_dataset( dataset: Optional[automl_translation.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. @@ -2613,8 +2679,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: @@ -2687,7 +2755,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]]] = (), ) -> automl_translation.Dataset: r"""Gets a Dataset. @@ -2730,8 +2798,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.translate_v3.types.Dataset: @@ -2793,7 +2863,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. @@ -2837,8 +2907,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.translate_v3.services.translation_service.pagers.ListDatasetsAsyncPager: @@ -2913,7 +2985,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. @@ -2960,8 +3032,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: @@ -3043,7 +3117,7 @@ async def create_adaptive_mt_dataset( adaptive_mt_dataset: Optional[adaptive_mt.AdaptiveMtDataset] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.AdaptiveMtDataset: r"""Creates an Adaptive MT dataset. @@ -3098,8 +3172,10 @@ async def sample_create_adaptive_mt_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.translate_v3.types.AdaptiveMtDataset: @@ -3162,7 +3238,7 @@ async def delete_adaptive_mt_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]]] = (), ) -> None: r"""Deletes an Adaptive MT dataset, including all its entries and associated metadata. @@ -3204,8 +3280,10 @@ async def sample_delete_adaptive_mt_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3257,7 +3335,7 @@ async def get_adaptive_mt_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]]] = (), ) -> adaptive_mt.AdaptiveMtDataset: r"""Gets the Adaptive MT dataset. @@ -3301,8 +3379,10 @@ async def sample_get_adaptive_mt_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.translate_v3.types.AdaptiveMtDataset: @@ -3363,7 +3443,7 @@ async def list_adaptive_mt_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.ListAdaptiveMtDatasetsAsyncPager: r"""Lists all Adaptive MT datasets for which the caller has read permission. @@ -3411,8 +3491,10 @@ async def sample_list_adaptive_mt_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.translate_v3.services.translation_service.pagers.ListAdaptiveMtDatasetsAsyncPager: @@ -3488,7 +3570,7 @@ async def adaptive_mt_translate( content: 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]]] = (), ) -> adaptive_mt.AdaptiveMtTranslateResponse: r"""Translate text using Adaptive MT. @@ -3543,8 +3625,10 @@ async def sample_adaptive_mt_translate(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.types.AdaptiveMtTranslateResponse: @@ -3605,7 +3689,7 @@ async def get_adaptive_mt_file( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.AdaptiveMtFile: r"""Gets and AdaptiveMtFile @@ -3649,8 +3733,10 @@ async def sample_get_adaptive_mt_file(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.types.AdaptiveMtFile: @@ -3709,7 +3795,7 @@ async def delete_adaptive_mt_file( name: Optional[str] = None, retry: OptionalRetry = 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 an AdaptiveMtFile along with its sentences. @@ -3751,8 +3837,10 @@ async def sample_delete_adaptive_mt_file(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -3804,7 +3892,7 @@ async def import_adaptive_mt_file( 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]]] = (), ) -> adaptive_mt.ImportAdaptiveMtFileResponse: r"""Imports an AdaptiveMtFile and adds all of its sentences into the AdaptiveMtDataset. @@ -3856,8 +3944,10 @@ async def sample_import_adaptive_mt_file(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.types.ImportAdaptiveMtFileResponse: @@ -3918,7 +4008,7 @@ async def list_adaptive_mt_files( 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.ListAdaptiveMtFilesAsyncPager: r"""Lists all AdaptiveMtFiles associated to an AdaptiveMtDataset. @@ -3965,8 +4055,10 @@ async def sample_list_adaptive_mt_files(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.services.translation_service.pagers.ListAdaptiveMtFilesAsyncPager: @@ -4043,7 +4135,7 @@ async def list_adaptive_mt_sentences( 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.ListAdaptiveMtSentencesAsyncPager: r"""Lists all AdaptiveMtSentences under a given file/dataset. @@ -4094,8 +4186,10 @@ async def sample_list_adaptive_mt_sentences(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.services.translation_service.pagers.ListAdaptiveMtSentencesAsyncPager: @@ -4171,7 +4265,7 @@ async def import_data( input_config: Optional[automl_translation.DatasetInputConfig] = None, retry: OptionalRetry = gapic_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 sentence pairs into translation Dataset. @@ -4225,8 +4319,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: @@ -4308,7 +4404,7 @@ async def export_data( output_config: Optional[automl_translation.DatasetOutputConfig] = None, retry: OptionalRetry = gapic_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. @@ -4367,8 +4463,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: @@ -4449,7 +4547,7 @@ async def list_examples( 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.ListExamplesAsyncPager: r"""Lists sentence pairs in the dataset. @@ -4493,8 +4591,10 @@ async def sample_list_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.cloud.translate_v3.services.translation_service.pagers.ListExamplesAsyncPager: @@ -4570,7 +4670,7 @@ async def create_model( model: Optional[automl_translation.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. @@ -4622,8 +4722,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: @@ -4697,7 +4799,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. @@ -4741,8 +4843,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.translate_v3.services.translation_service.pagers.ListModelsAsyncPager: @@ -4817,7 +4921,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]]] = (), ) -> automl_translation.Model: r"""Gets a model. @@ -4860,8 +4964,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.translate_v3.types.Model: @@ -4920,7 +5026,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. @@ -4967,8 +5073,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: @@ -5046,7 +5154,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. @@ -5057,8 +5165,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. @@ -5099,7 +5209,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. @@ -5110,8 +5220,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. @@ -5152,7 +5264,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. @@ -5168,8 +5280,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 """ @@ -5206,7 +5320,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. @@ -5221,8 +5335,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 """ @@ -5259,7 +5375,7 @@ async def wait_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"""Waits until the specified long-running operation is done or reaches at most a specified timeout, returning the latest state. @@ -5276,8 +5392,10 @@ async def wait_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. @@ -5318,7 +5436,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. @@ -5329,8 +5447,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. @@ -5371,7 +5491,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. @@ -5382,8 +5502,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-translate/google/cloud/translate_v3/services/translation_service/client.py b/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/client.py index 4cd600ec7dc1..f42d0570a00a 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/client.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_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 @@ -761,6 +771,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( @@ -827,6 +841,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.translation_v3.TranslationServiceClient`.", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "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.translation.v3.TranslationService", + "credentialsType": None, + }, + ) + def translate_text( self, request: Optional[Union[translation_service.TranslateTextRequest, dict]] = None, @@ -839,7 +876,7 @@ def translate_text( source_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]]] = (), ) -> translation_service.TranslateTextResponse: r"""Translates input text and returns translated text. @@ -965,8 +1002,10 @@ def sample_translate_text(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.types.TranslateTextResponse: @@ -1042,7 +1081,7 @@ def romanize_text( contents: 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]]] = (), ) -> translation_service.RomanizeTextResponse: r"""Romanize input text written in non-Latin scripts to Latin text. @@ -1103,8 +1142,10 @@ def sample_romanize_text(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.types.RomanizeTextResponse: @@ -1169,7 +1210,7 @@ def detect_language( content: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.DetectLanguageResponse: r"""Detects the language of text within a request. @@ -1257,8 +1298,10 @@ def sample_detect_language(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.types.DetectLanguageResponse: @@ -1326,7 +1369,7 @@ def get_supported_languages( display_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]]] = (), ) -> translation_service.SupportedLanguages: r"""Returns a list of supported languages for translation. @@ -1412,8 +1455,10 @@ def sample_get_supported_languages(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.types.SupportedLanguages: @@ -1476,7 +1521,7 @@ def translate_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]]] = (), ) -> translation_service.TranslateDocumentResponse: r"""Translates documents in synchronous mode. @@ -1517,8 +1562,10 @@ def sample_translate_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.translate_v3.types.TranslateDocumentResponse: @@ -1564,7 +1611,7 @@ def batch_translate_text( *, retry: OptionalRetry = gapic_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"""Translates a large volume of text in asynchronous batch mode. This function provides real-time output as @@ -1623,8 +1670,10 @@ def sample_batch_translate_text(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1689,7 +1738,7 @@ def batch_translate_document( output_config: Optional[translation_service.BatchDocumentOutputConfig] = None, retry: OptionalRetry = gapic_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"""Translates a large volume of document in asynchronous batch mode. This function provides real-time output as @@ -1803,8 +1852,10 @@ def sample_batch_translate_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: @@ -1893,7 +1944,7 @@ def create_glossary( glossary: Optional[translation_service.Glossary] = None, retry: OptionalRetry = gapic_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 glossary and returns the long-running operation. Returns NOT_FOUND, if the project doesn't exist. @@ -1948,8 +1999,10 @@ def sample_create_glossary(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2023,7 +2076,7 @@ def update_glossary( 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 glossary. A LRO is used since the update can be async if the glossary's entry file is updated. @@ -2082,8 +2135,10 @@ def sample_update_glossary(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2158,7 +2213,7 @@ def list_glossaries( 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.ListGlossariesPager: r"""Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. @@ -2204,8 +2259,10 @@ def sample_list_glossaries(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.services.translation_service.pagers.ListGlossariesPager: @@ -2277,7 +2334,7 @@ def get_glossary( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.Glossary: r"""Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist. @@ -2321,8 +2378,10 @@ def sample_get_glossary(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.types.Glossary: @@ -2382,7 +2441,7 @@ def delete_glossary( name: Optional[str] = None, retry: OptionalRetry = gapic_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 glossary, or cancels glossary construction if the glossary isn't created yet. Returns NOT_FOUND, if the glossary @@ -2431,8 +2490,10 @@ def sample_delete_glossary(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2503,7 +2564,7 @@ def get_glossary_entry( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.GlossaryEntry: r"""Gets a single glossary entry by the given id. @@ -2547,8 +2608,10 @@ def sample_get_glossary_entry(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.types.GlossaryEntry: @@ -2608,7 +2671,7 @@ def list_glossary_entries( 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.ListGlossaryEntriesPager: r"""List the entries for the glossary. @@ -2654,8 +2717,10 @@ def sample_list_glossary_entries(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.services.translation_service.pagers.ListGlossaryEntriesPager: @@ -2730,7 +2795,7 @@ def create_glossary_entry( glossary_entry: Optional[common.GlossaryEntry] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.GlossaryEntry: r"""Creates a glossary entry. @@ -2781,8 +2846,10 @@ def sample_create_glossary_entry(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.types.GlossaryEntry: @@ -2844,7 +2911,7 @@ def update_glossary_entry( glossary_entry: Optional[common.GlossaryEntry] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.GlossaryEntry: r"""Updates a glossary entry. @@ -2887,8 +2954,10 @@ def sample_update_glossary_entry(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.types.GlossaryEntry: @@ -2950,7 +3019,7 @@ def delete_glossary_entry( name: Optional[str] = None, retry: OptionalRetry = 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 entry from the glossary @@ -2991,8 +3060,10 @@ def sample_delete_glossary_entry(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -3042,7 +3113,7 @@ def create_dataset( dataset: Optional[automl_translation.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. @@ -3092,8 +3163,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: @@ -3163,7 +3236,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]]] = (), ) -> automl_translation.Dataset: r"""Gets a Dataset. @@ -3206,8 +3279,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.translate_v3.types.Dataset: @@ -3266,7 +3341,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. @@ -3310,8 +3385,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.translate_v3.services.translation_service.pagers.ListDatasetsPager: @@ -3383,7 +3460,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. @@ -3430,8 +3507,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: @@ -3510,7 +3589,7 @@ def create_adaptive_mt_dataset( adaptive_mt_dataset: Optional[adaptive_mt.AdaptiveMtDataset] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.AdaptiveMtDataset: r"""Creates an Adaptive MT dataset. @@ -3565,8 +3644,10 @@ def sample_create_adaptive_mt_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.translate_v3.types.AdaptiveMtDataset: @@ -3628,7 +3709,7 @@ def delete_adaptive_mt_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]]] = (), ) -> None: r"""Deletes an Adaptive MT dataset, including all its entries and associated metadata. @@ -3670,8 +3751,10 @@ def sample_delete_adaptive_mt_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3722,7 +3805,7 @@ def get_adaptive_mt_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]]] = (), ) -> adaptive_mt.AdaptiveMtDataset: r"""Gets the Adaptive MT dataset. @@ -3766,8 +3849,10 @@ def sample_get_adaptive_mt_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.translate_v3.types.AdaptiveMtDataset: @@ -3825,7 +3910,7 @@ def list_adaptive_mt_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.ListAdaptiveMtDatasetsPager: r"""Lists all Adaptive MT datasets for which the caller has read permission. @@ -3873,8 +3958,10 @@ def sample_list_adaptive_mt_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.translate_v3.services.translation_service.pagers.ListAdaptiveMtDatasetsPager: @@ -3949,7 +4036,7 @@ def adaptive_mt_translate( content: 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]]] = (), ) -> adaptive_mt.AdaptiveMtTranslateResponse: r"""Translate text using Adaptive MT. @@ -4004,8 +4091,10 @@ def sample_adaptive_mt_translate(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.types.AdaptiveMtTranslateResponse: @@ -4063,7 +4152,7 @@ def get_adaptive_mt_file( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.AdaptiveMtFile: r"""Gets and AdaptiveMtFile @@ -4107,8 +4196,10 @@ def sample_get_adaptive_mt_file(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.types.AdaptiveMtFile: @@ -4164,7 +4255,7 @@ def delete_adaptive_mt_file( name: Optional[str] = None, retry: OptionalRetry = 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 an AdaptiveMtFile along with its sentences. @@ -4206,8 +4297,10 @@ def sample_delete_adaptive_mt_file(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -4256,7 +4349,7 @@ def import_adaptive_mt_file( 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]]] = (), ) -> adaptive_mt.ImportAdaptiveMtFileResponse: r"""Imports an AdaptiveMtFile and adds all of its sentences into the AdaptiveMtDataset. @@ -4308,8 +4401,10 @@ def sample_import_adaptive_mt_file(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.types.ImportAdaptiveMtFileResponse: @@ -4367,7 +4462,7 @@ def list_adaptive_mt_files( 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.ListAdaptiveMtFilesPager: r"""Lists all AdaptiveMtFiles associated to an AdaptiveMtDataset. @@ -4414,8 +4509,10 @@ def sample_list_adaptive_mt_files(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.services.translation_service.pagers.ListAdaptiveMtFilesPager: @@ -4489,7 +4586,7 @@ def list_adaptive_mt_sentences( 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.ListAdaptiveMtSentencesPager: r"""Lists all AdaptiveMtSentences under a given file/dataset. @@ -4540,8 +4637,10 @@ def sample_list_adaptive_mt_sentences(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3.services.translation_service.pagers.ListAdaptiveMtSentencesPager: @@ -4616,7 +4715,7 @@ def import_data( input_config: Optional[automl_translation.DatasetInputConfig] = None, retry: OptionalRetry = gapic_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 sentence pairs into translation Dataset. @@ -4670,8 +4769,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: @@ -4750,7 +4851,7 @@ def export_data( output_config: Optional[automl_translation.DatasetOutputConfig] = None, retry: OptionalRetry = gapic_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. @@ -4809,8 +4910,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: @@ -4888,7 +4991,7 @@ def list_examples( 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.ListExamplesPager: r"""Lists sentence pairs in the dataset. @@ -4932,8 +5035,10 @@ def sample_list_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.cloud.translate_v3.services.translation_service.pagers.ListExamplesPager: @@ -5006,7 +5111,7 @@ def create_model( model: Optional[automl_translation.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. @@ -5058,8 +5163,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: @@ -5130,7 +5237,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. @@ -5174,8 +5281,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.translate_v3.services.translation_service.pagers.ListModelsPager: @@ -5247,7 +5356,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]]] = (), ) -> automl_translation.Model: r"""Gets a model. @@ -5290,8 +5399,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.translate_v3.types.Model: @@ -5347,7 +5458,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. @@ -5394,8 +5505,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: @@ -5483,7 +5596,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. @@ -5494,8 +5607,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. @@ -5536,7 +5651,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. @@ -5547,8 +5662,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. @@ -5589,7 +5706,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. @@ -5605,8 +5722,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 """ @@ -5643,7 +5762,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. @@ -5658,8 +5777,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 """ @@ -5696,7 +5817,7 @@ def wait_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"""Waits until the specified long-running operation is done or reaches at most a specified timeout, returning the latest state. @@ -5713,8 +5834,10 @@ def wait_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. @@ -5755,7 +5878,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. @@ -5766,8 +5889,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. @@ -5808,7 +5933,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. @@ -5819,8 +5944,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-translate/google/cloud/translate_v3/services/translation_service/pagers.py b/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/pagers.py index dffa95ae680c..27bb1887dbbf 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/pagers.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/pagers.py @@ -72,7 +72,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -86,8 +86,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = translation_service.ListGlossariesRequest(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 = translation_service.ListGlossariesRequest(request) @@ -224,7 +228,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -238,8 +242,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = translation_service.ListGlossaryEntriesRequest(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 = translation_service.ListGlossaryEntriesRequest(request) @@ -380,7 +388,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -394,8 +402,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = automl_translation.ListDatasetsRequest(request) @@ -454,7 +464,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. @@ -468,8 +478,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 = automl_translation.ListDatasetsRequest(request) @@ -532,7 +544,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -546,8 +558,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = adaptive_mt.ListAdaptiveMtDatasetsRequest(request) @@ -606,7 +620,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. @@ -620,8 +634,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 = adaptive_mt.ListAdaptiveMtDatasetsRequest(request) @@ -684,7 +700,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -698,8 +714,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = adaptive_mt.ListAdaptiveMtFilesRequest(request) @@ -758,7 +776,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. @@ -772,8 +790,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 = adaptive_mt.ListAdaptiveMtFilesRequest(request) @@ -836,7 +856,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -850,8 +870,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = adaptive_mt.ListAdaptiveMtSentencesRequest(request) @@ -910,7 +932,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. @@ -924,8 +946,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 = adaptive_mt.ListAdaptiveMtSentencesRequest(request) @@ -988,7 +1012,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1002,8 +1026,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = automl_translation.ListExamplesRequest(request) @@ -1062,7 +1088,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. @@ -1076,8 +1102,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 = automl_translation.ListExamplesRequest(request) @@ -1140,7 +1168,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1154,8 +1182,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = automl_translation.ListModelsRequest(request) @@ -1214,7 +1244,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. @@ -1228,8 +1258,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 = automl_translation.ListModelsRequest(request) diff --git a/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/transports/grpc.py b/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/transports/grpc.py index f2effd13612c..7187ff19bb97 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/transports/grpc.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_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 @@ -25,7 +28,10 @@ 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.translate_v3.types import ( adaptive_mt, @@ -36,6 +42,81 @@ from .base import DEFAULT_CLIENT_INFO, TranslationServiceTransport +try: + from google.api_core import client_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.translation.v3.TranslationService", + "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.translation.v3.TranslationService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TranslationServiceGrpcTransport(TranslationServiceTransport): """gRPC backend transport for TranslationService. @@ -190,7 +271,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 @@ -254,7 +340,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 @@ -281,7 +369,7 @@ def translate_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "translate_text" not in self._stubs: - self._stubs["translate_text"] = self.grpc_channel.unary_unary( + self._stubs["translate_text"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/TranslateText", request_serializer=translation_service.TranslateTextRequest.serialize, response_deserializer=translation_service.TranslateTextResponse.deserialize, @@ -311,7 +399,7 @@ def romanize_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "romanize_text" not in self._stubs: - self._stubs["romanize_text"] = self.grpc_channel.unary_unary( + self._stubs["romanize_text"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/RomanizeText", request_serializer=translation_service.RomanizeTextRequest.serialize, response_deserializer=translation_service.RomanizeTextResponse.deserialize, @@ -340,7 +428,7 @@ def detect_language( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "detect_language" not in self._stubs: - self._stubs["detect_language"] = self.grpc_channel.unary_unary( + self._stubs["detect_language"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/DetectLanguage", request_serializer=translation_service.DetectLanguageRequest.serialize, response_deserializer=translation_service.DetectLanguageResponse.deserialize, @@ -370,7 +458,7 @@ def get_supported_languages( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_supported_languages" not in self._stubs: - self._stubs["get_supported_languages"] = self.grpc_channel.unary_unary( + self._stubs["get_supported_languages"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/GetSupportedLanguages", request_serializer=translation_service.GetSupportedLanguagesRequest.serialize, response_deserializer=translation_service.SupportedLanguages.deserialize, @@ -399,7 +487,7 @@ def translate_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "translate_document" not in self._stubs: - self._stubs["translate_document"] = self.grpc_channel.unary_unary( + self._stubs["translate_document"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/TranslateDocument", request_serializer=translation_service.TranslateDocumentRequest.serialize, response_deserializer=translation_service.TranslateDocumentResponse.deserialize, @@ -436,7 +524,7 @@ def batch_translate_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_translate_text" not in self._stubs: - self._stubs["batch_translate_text"] = self.grpc_channel.unary_unary( + self._stubs["batch_translate_text"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/BatchTranslateText", request_serializer=translation_service.BatchTranslateTextRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -473,7 +561,7 @@ def batch_translate_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_translate_document" not in self._stubs: - self._stubs["batch_translate_document"] = self.grpc_channel.unary_unary( + self._stubs["batch_translate_document"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/BatchTranslateDocument", request_serializer=translation_service.BatchTranslateDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -502,7 +590,7 @@ def create_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_glossary" not in self._stubs: - self._stubs["create_glossary"] = self.grpc_channel.unary_unary( + self._stubs["create_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/CreateGlossary", request_serializer=translation_service.CreateGlossaryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -531,7 +619,7 @@ def update_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_glossary" not in self._stubs: - self._stubs["update_glossary"] = self.grpc_channel.unary_unary( + self._stubs["update_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/UpdateGlossary", request_serializer=translation_service.UpdateGlossaryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -561,7 +649,7 @@ def list_glossaries( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_glossaries" not in self._stubs: - self._stubs["list_glossaries"] = self.grpc_channel.unary_unary( + self._stubs["list_glossaries"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListGlossaries", request_serializer=translation_service.ListGlossariesRequest.serialize, response_deserializer=translation_service.ListGlossariesResponse.deserialize, @@ -590,7 +678,7 @@ def get_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_glossary" not in self._stubs: - self._stubs["get_glossary"] = self.grpc_channel.unary_unary( + self._stubs["get_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/GetGlossary", request_serializer=translation_service.GetGlossaryRequest.serialize, response_deserializer=translation_service.Glossary.deserialize, @@ -620,7 +708,7 @@ def delete_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_glossary" not in self._stubs: - self._stubs["delete_glossary"] = self.grpc_channel.unary_unary( + self._stubs["delete_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/DeleteGlossary", request_serializer=translation_service.DeleteGlossaryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -646,7 +734,7 @@ def get_glossary_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_glossary_entry" not in self._stubs: - self._stubs["get_glossary_entry"] = self.grpc_channel.unary_unary( + self._stubs["get_glossary_entry"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/GetGlossaryEntry", request_serializer=translation_service.GetGlossaryEntryRequest.serialize, response_deserializer=common.GlossaryEntry.deserialize, @@ -675,7 +763,7 @@ def list_glossary_entries( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_glossary_entries" not in self._stubs: - self._stubs["list_glossary_entries"] = self.grpc_channel.unary_unary( + self._stubs["list_glossary_entries"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListGlossaryEntries", request_serializer=translation_service.ListGlossaryEntriesRequest.serialize, response_deserializer=translation_service.ListGlossaryEntriesResponse.deserialize, @@ -703,7 +791,7 @@ def create_glossary_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_glossary_entry" not in self._stubs: - self._stubs["create_glossary_entry"] = self.grpc_channel.unary_unary( + self._stubs["create_glossary_entry"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/CreateGlossaryEntry", request_serializer=translation_service.CreateGlossaryEntryRequest.serialize, response_deserializer=common.GlossaryEntry.deserialize, @@ -731,7 +819,7 @@ def update_glossary_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_glossary_entry" not in self._stubs: - self._stubs["update_glossary_entry"] = self.grpc_channel.unary_unary( + self._stubs["update_glossary_entry"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/UpdateGlossaryEntry", request_serializer=translation_service.UpdateGlossaryEntryRequest.serialize, response_deserializer=common.GlossaryEntry.deserialize, @@ -757,7 +845,7 @@ def delete_glossary_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_glossary_entry" not in self._stubs: - self._stubs["delete_glossary_entry"] = self.grpc_channel.unary_unary( + self._stubs["delete_glossary_entry"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/DeleteGlossaryEntry", request_serializer=translation_service.DeleteGlossaryEntryRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -783,7 +871,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.translation.v3.TranslationService/CreateDataset", request_serializer=automl_translation.CreateDatasetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -809,7 +897,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.translation.v3.TranslationService/GetDataset", request_serializer=automl_translation.GetDatasetRequest.serialize, response_deserializer=automl_translation.Dataset.deserialize, @@ -838,7 +926,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.translation.v3.TranslationService/ListDatasets", request_serializer=automl_translation.ListDatasetsRequest.serialize, response_deserializer=automl_translation.ListDatasetsResponse.deserialize, @@ -864,7 +952,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.translation.v3.TranslationService/DeleteDataset", request_serializer=automl_translation.DeleteDatasetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -892,7 +980,9 @@ def create_adaptive_mt_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_adaptive_mt_dataset" not in self._stubs: - self._stubs["create_adaptive_mt_dataset"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_adaptive_mt_dataset" + ] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/CreateAdaptiveMtDataset", request_serializer=adaptive_mt.CreateAdaptiveMtDatasetRequest.serialize, response_deserializer=adaptive_mt.AdaptiveMtDataset.deserialize, @@ -919,7 +1009,9 @@ def delete_adaptive_mt_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_adaptive_mt_dataset" not in self._stubs: - self._stubs["delete_adaptive_mt_dataset"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_adaptive_mt_dataset" + ] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/DeleteAdaptiveMtDataset", request_serializer=adaptive_mt.DeleteAdaptiveMtDatasetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -947,7 +1039,7 @@ def get_adaptive_mt_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_adaptive_mt_dataset" not in self._stubs: - self._stubs["get_adaptive_mt_dataset"] = self.grpc_channel.unary_unary( + self._stubs["get_adaptive_mt_dataset"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/GetAdaptiveMtDataset", request_serializer=adaptive_mt.GetAdaptiveMtDatasetRequest.serialize, response_deserializer=adaptive_mt.AdaptiveMtDataset.deserialize, @@ -977,7 +1069,7 @@ def list_adaptive_mt_datasets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_adaptive_mt_datasets" not in self._stubs: - self._stubs["list_adaptive_mt_datasets"] = self.grpc_channel.unary_unary( + self._stubs["list_adaptive_mt_datasets"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListAdaptiveMtDatasets", request_serializer=adaptive_mt.ListAdaptiveMtDatasetsRequest.serialize, response_deserializer=adaptive_mt.ListAdaptiveMtDatasetsResponse.deserialize, @@ -1006,7 +1098,7 @@ def adaptive_mt_translate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "adaptive_mt_translate" not in self._stubs: - self._stubs["adaptive_mt_translate"] = self.grpc_channel.unary_unary( + self._stubs["adaptive_mt_translate"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/AdaptiveMtTranslate", request_serializer=adaptive_mt.AdaptiveMtTranslateRequest.serialize, response_deserializer=adaptive_mt.AdaptiveMtTranslateResponse.deserialize, @@ -1032,7 +1124,7 @@ def get_adaptive_mt_file( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_adaptive_mt_file" not in self._stubs: - self._stubs["get_adaptive_mt_file"] = self.grpc_channel.unary_unary( + self._stubs["get_adaptive_mt_file"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/GetAdaptiveMtFile", request_serializer=adaptive_mt.GetAdaptiveMtFileRequest.serialize, response_deserializer=adaptive_mt.AdaptiveMtFile.deserialize, @@ -1058,7 +1150,7 @@ def delete_adaptive_mt_file( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_adaptive_mt_file" not in self._stubs: - self._stubs["delete_adaptive_mt_file"] = self.grpc_channel.unary_unary( + self._stubs["delete_adaptive_mt_file"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/DeleteAdaptiveMtFile", request_serializer=adaptive_mt.DeleteAdaptiveMtFileRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1088,7 +1180,7 @@ def import_adaptive_mt_file( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_adaptive_mt_file" not in self._stubs: - self._stubs["import_adaptive_mt_file"] = self.grpc_channel.unary_unary( + self._stubs["import_adaptive_mt_file"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ImportAdaptiveMtFile", request_serializer=adaptive_mt.ImportAdaptiveMtFileRequest.serialize, response_deserializer=adaptive_mt.ImportAdaptiveMtFileResponse.deserialize, @@ -1118,7 +1210,7 @@ def list_adaptive_mt_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_adaptive_mt_files" not in self._stubs: - self._stubs["list_adaptive_mt_files"] = self.grpc_channel.unary_unary( + self._stubs["list_adaptive_mt_files"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListAdaptiveMtFiles", request_serializer=adaptive_mt.ListAdaptiveMtFilesRequest.serialize, response_deserializer=adaptive_mt.ListAdaptiveMtFilesResponse.deserialize, @@ -1148,7 +1240,9 @@ def list_adaptive_mt_sentences( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_adaptive_mt_sentences" not in self._stubs: - self._stubs["list_adaptive_mt_sentences"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_adaptive_mt_sentences" + ] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListAdaptiveMtSentences", request_serializer=adaptive_mt.ListAdaptiveMtSentencesRequest.serialize, response_deserializer=adaptive_mt.ListAdaptiveMtSentencesResponse.deserialize, @@ -1174,7 +1268,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.translation.v3.TranslationService/ImportData", request_serializer=automl_translation.ImportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1201,7 +1295,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.translation.v3.TranslationService/ExportData", request_serializer=automl_translation.ExportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1230,7 +1324,7 @@ def list_examples( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_examples" not in self._stubs: - self._stubs["list_examples"] = self.grpc_channel.unary_unary( + self._stubs["list_examples"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListExamples", request_serializer=automl_translation.ListExamplesRequest.serialize, response_deserializer=automl_translation.ListExamplesResponse.deserialize, @@ -1256,7 +1350,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.translation.v3.TranslationService/CreateModel", request_serializer=automl_translation.CreateModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1284,7 +1378,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.translation.v3.TranslationService/ListModels", request_serializer=automl_translation.ListModelsRequest.serialize, response_deserializer=automl_translation.ListModelsResponse.deserialize, @@ -1310,7 +1404,7 @@ def get_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.translation.v3.TranslationService/GetModel", request_serializer=automl_translation.GetModelRequest.serialize, response_deserializer=automl_translation.Model.deserialize, @@ -1336,7 +1430,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.translation.v3.TranslationService/DeleteModel", request_serializer=automl_translation.DeleteModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1344,7 +1438,7 @@ def delete_model( return self._stubs["delete_model"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -1356,7 +1450,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, @@ -1373,7 +1467,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, @@ -1390,7 +1484,7 @@ def wait_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "wait_operation" not in self._stubs: - self._stubs["wait_operation"] = self.grpc_channel.unary_unary( + self._stubs["wait_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/WaitOperation", request_serializer=operations_pb2.WaitOperationRequest.SerializeToString, response_deserializer=None, @@ -1407,7 +1501,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, @@ -1426,7 +1520,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, @@ -1445,7 +1539,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, @@ -1462,7 +1556,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-translate/google/cloud/translate_v3/services/translation_service/transports/grpc_asyncio.py b/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/transports/grpc_asyncio.py index 7a7dcffd0ad2..1712f606af99 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_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 @@ -27,8 +30,11 @@ 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.translate_v3.types import ( adaptive_mt, @@ -40,6 +46,82 @@ from .base import DEFAULT_CLIENT_INFO, TranslationServiceTransport from .grpc import TranslationServiceGrpcTransport +try: + from google.api_core import client_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.translation.v3.TranslationService", + "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.translation.v3.TranslationService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TranslationServiceGrpcAsyncIOTransport(TranslationServiceTransport): """gRPC AsyncIO backend transport for TranslationService. @@ -237,10 +319,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 @@ -263,7 +348,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. @@ -291,7 +376,7 @@ def translate_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "translate_text" not in self._stubs: - self._stubs["translate_text"] = self.grpc_channel.unary_unary( + self._stubs["translate_text"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/TranslateText", request_serializer=translation_service.TranslateTextRequest.serialize, response_deserializer=translation_service.TranslateTextResponse.deserialize, @@ -321,7 +406,7 @@ def romanize_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "romanize_text" not in self._stubs: - self._stubs["romanize_text"] = self.grpc_channel.unary_unary( + self._stubs["romanize_text"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/RomanizeText", request_serializer=translation_service.RomanizeTextRequest.serialize, response_deserializer=translation_service.RomanizeTextResponse.deserialize, @@ -350,7 +435,7 @@ def detect_language( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "detect_language" not in self._stubs: - self._stubs["detect_language"] = self.grpc_channel.unary_unary( + self._stubs["detect_language"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/DetectLanguage", request_serializer=translation_service.DetectLanguageRequest.serialize, response_deserializer=translation_service.DetectLanguageResponse.deserialize, @@ -380,7 +465,7 @@ def get_supported_languages( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_supported_languages" not in self._stubs: - self._stubs["get_supported_languages"] = self.grpc_channel.unary_unary( + self._stubs["get_supported_languages"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/GetSupportedLanguages", request_serializer=translation_service.GetSupportedLanguagesRequest.serialize, response_deserializer=translation_service.SupportedLanguages.deserialize, @@ -409,7 +494,7 @@ def translate_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "translate_document" not in self._stubs: - self._stubs["translate_document"] = self.grpc_channel.unary_unary( + self._stubs["translate_document"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/TranslateDocument", request_serializer=translation_service.TranslateDocumentRequest.serialize, response_deserializer=translation_service.TranslateDocumentResponse.deserialize, @@ -447,7 +532,7 @@ def batch_translate_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_translate_text" not in self._stubs: - self._stubs["batch_translate_text"] = self.grpc_channel.unary_unary( + self._stubs["batch_translate_text"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/BatchTranslateText", request_serializer=translation_service.BatchTranslateTextRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -485,7 +570,7 @@ def batch_translate_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_translate_document" not in self._stubs: - self._stubs["batch_translate_document"] = self.grpc_channel.unary_unary( + self._stubs["batch_translate_document"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/BatchTranslateDocument", request_serializer=translation_service.BatchTranslateDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -514,7 +599,7 @@ def create_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_glossary" not in self._stubs: - self._stubs["create_glossary"] = self.grpc_channel.unary_unary( + self._stubs["create_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/CreateGlossary", request_serializer=translation_service.CreateGlossaryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -543,7 +628,7 @@ def update_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_glossary" not in self._stubs: - self._stubs["update_glossary"] = self.grpc_channel.unary_unary( + self._stubs["update_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/UpdateGlossary", request_serializer=translation_service.UpdateGlossaryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -573,7 +658,7 @@ def list_glossaries( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_glossaries" not in self._stubs: - self._stubs["list_glossaries"] = self.grpc_channel.unary_unary( + self._stubs["list_glossaries"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListGlossaries", request_serializer=translation_service.ListGlossariesRequest.serialize, response_deserializer=translation_service.ListGlossariesResponse.deserialize, @@ -603,7 +688,7 @@ def get_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_glossary" not in self._stubs: - self._stubs["get_glossary"] = self.grpc_channel.unary_unary( + self._stubs["get_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/GetGlossary", request_serializer=translation_service.GetGlossaryRequest.serialize, response_deserializer=translation_service.Glossary.deserialize, @@ -633,7 +718,7 @@ def delete_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_glossary" not in self._stubs: - self._stubs["delete_glossary"] = self.grpc_channel.unary_unary( + self._stubs["delete_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/DeleteGlossary", request_serializer=translation_service.DeleteGlossaryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -661,7 +746,7 @@ def get_glossary_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_glossary_entry" not in self._stubs: - self._stubs["get_glossary_entry"] = self.grpc_channel.unary_unary( + self._stubs["get_glossary_entry"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/GetGlossaryEntry", request_serializer=translation_service.GetGlossaryEntryRequest.serialize, response_deserializer=common.GlossaryEntry.deserialize, @@ -690,7 +775,7 @@ def list_glossary_entries( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_glossary_entries" not in self._stubs: - self._stubs["list_glossary_entries"] = self.grpc_channel.unary_unary( + self._stubs["list_glossary_entries"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListGlossaryEntries", request_serializer=translation_service.ListGlossaryEntriesRequest.serialize, response_deserializer=translation_service.ListGlossaryEntriesResponse.deserialize, @@ -719,7 +804,7 @@ def create_glossary_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_glossary_entry" not in self._stubs: - self._stubs["create_glossary_entry"] = self.grpc_channel.unary_unary( + self._stubs["create_glossary_entry"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/CreateGlossaryEntry", request_serializer=translation_service.CreateGlossaryEntryRequest.serialize, response_deserializer=common.GlossaryEntry.deserialize, @@ -748,7 +833,7 @@ def update_glossary_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_glossary_entry" not in self._stubs: - self._stubs["update_glossary_entry"] = self.grpc_channel.unary_unary( + self._stubs["update_glossary_entry"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/UpdateGlossaryEntry", request_serializer=translation_service.UpdateGlossaryEntryRequest.serialize, response_deserializer=common.GlossaryEntry.deserialize, @@ -776,7 +861,7 @@ def delete_glossary_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_glossary_entry" not in self._stubs: - self._stubs["delete_glossary_entry"] = self.grpc_channel.unary_unary( + self._stubs["delete_glossary_entry"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/DeleteGlossaryEntry", request_serializer=translation_service.DeleteGlossaryEntryRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -804,7 +889,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.translation.v3.TranslationService/CreateDataset", request_serializer=automl_translation.CreateDatasetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -832,7 +917,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.translation.v3.TranslationService/GetDataset", request_serializer=automl_translation.GetDatasetRequest.serialize, response_deserializer=automl_translation.Dataset.deserialize, @@ -861,7 +946,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.translation.v3.TranslationService/ListDatasets", request_serializer=automl_translation.ListDatasetsRequest.serialize, response_deserializer=automl_translation.ListDatasetsResponse.deserialize, @@ -889,7 +974,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.translation.v3.TranslationService/DeleteDataset", request_serializer=automl_translation.DeleteDatasetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -918,7 +1003,9 @@ def create_adaptive_mt_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_adaptive_mt_dataset" not in self._stubs: - self._stubs["create_adaptive_mt_dataset"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_adaptive_mt_dataset" + ] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/CreateAdaptiveMtDataset", request_serializer=adaptive_mt.CreateAdaptiveMtDatasetRequest.serialize, response_deserializer=adaptive_mt.AdaptiveMtDataset.deserialize, @@ -947,7 +1034,9 @@ def delete_adaptive_mt_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_adaptive_mt_dataset" not in self._stubs: - self._stubs["delete_adaptive_mt_dataset"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_adaptive_mt_dataset" + ] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/DeleteAdaptiveMtDataset", request_serializer=adaptive_mt.DeleteAdaptiveMtDatasetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -976,7 +1065,7 @@ def get_adaptive_mt_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_adaptive_mt_dataset" not in self._stubs: - self._stubs["get_adaptive_mt_dataset"] = self.grpc_channel.unary_unary( + self._stubs["get_adaptive_mt_dataset"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/GetAdaptiveMtDataset", request_serializer=adaptive_mt.GetAdaptiveMtDatasetRequest.serialize, response_deserializer=adaptive_mt.AdaptiveMtDataset.deserialize, @@ -1006,7 +1095,7 @@ def list_adaptive_mt_datasets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_adaptive_mt_datasets" not in self._stubs: - self._stubs["list_adaptive_mt_datasets"] = self.grpc_channel.unary_unary( + self._stubs["list_adaptive_mt_datasets"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListAdaptiveMtDatasets", request_serializer=adaptive_mt.ListAdaptiveMtDatasetsRequest.serialize, response_deserializer=adaptive_mt.ListAdaptiveMtDatasetsResponse.deserialize, @@ -1035,7 +1124,7 @@ def adaptive_mt_translate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "adaptive_mt_translate" not in self._stubs: - self._stubs["adaptive_mt_translate"] = self.grpc_channel.unary_unary( + self._stubs["adaptive_mt_translate"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/AdaptiveMtTranslate", request_serializer=adaptive_mt.AdaptiveMtTranslateRequest.serialize, response_deserializer=adaptive_mt.AdaptiveMtTranslateResponse.deserialize, @@ -1063,7 +1152,7 @@ def get_adaptive_mt_file( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_adaptive_mt_file" not in self._stubs: - self._stubs["get_adaptive_mt_file"] = self.grpc_channel.unary_unary( + self._stubs["get_adaptive_mt_file"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/GetAdaptiveMtFile", request_serializer=adaptive_mt.GetAdaptiveMtFileRequest.serialize, response_deserializer=adaptive_mt.AdaptiveMtFile.deserialize, @@ -1091,7 +1180,7 @@ def delete_adaptive_mt_file( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_adaptive_mt_file" not in self._stubs: - self._stubs["delete_adaptive_mt_file"] = self.grpc_channel.unary_unary( + self._stubs["delete_adaptive_mt_file"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/DeleteAdaptiveMtFile", request_serializer=adaptive_mt.DeleteAdaptiveMtFileRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1121,7 +1210,7 @@ def import_adaptive_mt_file( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_adaptive_mt_file" not in self._stubs: - self._stubs["import_adaptive_mt_file"] = self.grpc_channel.unary_unary( + self._stubs["import_adaptive_mt_file"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ImportAdaptiveMtFile", request_serializer=adaptive_mt.ImportAdaptiveMtFileRequest.serialize, response_deserializer=adaptive_mt.ImportAdaptiveMtFileResponse.deserialize, @@ -1151,7 +1240,7 @@ def list_adaptive_mt_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_adaptive_mt_files" not in self._stubs: - self._stubs["list_adaptive_mt_files"] = self.grpc_channel.unary_unary( + self._stubs["list_adaptive_mt_files"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListAdaptiveMtFiles", request_serializer=adaptive_mt.ListAdaptiveMtFilesRequest.serialize, response_deserializer=adaptive_mt.ListAdaptiveMtFilesResponse.deserialize, @@ -1181,7 +1270,9 @@ def list_adaptive_mt_sentences( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_adaptive_mt_sentences" not in self._stubs: - self._stubs["list_adaptive_mt_sentences"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_adaptive_mt_sentences" + ] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListAdaptiveMtSentences", request_serializer=adaptive_mt.ListAdaptiveMtSentencesRequest.serialize, response_deserializer=adaptive_mt.ListAdaptiveMtSentencesResponse.deserialize, @@ -1209,7 +1300,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.translation.v3.TranslationService/ImportData", request_serializer=automl_translation.ImportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1238,7 +1329,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.translation.v3.TranslationService/ExportData", request_serializer=automl_translation.ExportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1267,7 +1358,7 @@ def list_examples( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_examples" not in self._stubs: - self._stubs["list_examples"] = self.grpc_channel.unary_unary( + self._stubs["list_examples"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListExamples", request_serializer=automl_translation.ListExamplesRequest.serialize, response_deserializer=automl_translation.ListExamplesResponse.deserialize, @@ -1295,7 +1386,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.translation.v3.TranslationService/CreateModel", request_serializer=automl_translation.CreateModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1324,7 +1415,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.translation.v3.TranslationService/ListModels", request_serializer=automl_translation.ListModelsRequest.serialize, response_deserializer=automl_translation.ListModelsResponse.deserialize, @@ -1352,7 +1443,7 @@ def get_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.translation.v3.TranslationService/GetModel", request_serializer=automl_translation.GetModelRequest.serialize, response_deserializer=automl_translation.Model.deserialize, @@ -1380,7 +1471,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.translation.v3.TranslationService/DeleteModel", request_serializer=automl_translation.DeleteModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1663,7 +1754,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: @@ -1679,7 +1770,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, @@ -1696,7 +1787,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, @@ -1713,7 +1804,7 @@ def wait_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "wait_operation" not in self._stubs: - self._stubs["wait_operation"] = self.grpc_channel.unary_unary( + self._stubs["wait_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/WaitOperation", request_serializer=operations_pb2.WaitOperationRequest.SerializeToString, response_deserializer=None, @@ -1730,7 +1821,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, @@ -1749,7 +1840,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, @@ -1768,7 +1859,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, @@ -1785,7 +1876,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-translate/google/cloud/translate_v3/services/translation_service/transports/rest.py b/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/transports/rest.py index a97c73752636..06abe7a126fb 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/transports/rest.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_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 @@ -47,6 +47,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, @@ -371,8 +379,10 @@ def post_update_glossary_entry(self, response): def pre_adaptive_mt_translate( self, request: adaptive_mt.AdaptiveMtTranslateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[adaptive_mt.AdaptiveMtTranslateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + adaptive_mt.AdaptiveMtTranslateRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for adaptive_mt_translate Override in a subclass to manipulate the request or metadata @@ -394,9 +404,10 @@ def post_adaptive_mt_translate( def pre_batch_translate_document( self, request: translation_service.BatchTranslateDocumentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - translation_service.BatchTranslateDocumentRequest, Sequence[Tuple[str, str]] + translation_service.BatchTranslateDocumentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for batch_translate_document @@ -419,9 +430,10 @@ def post_batch_translate_document( def pre_batch_translate_text( self, request: translation_service.BatchTranslateTextRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - translation_service.BatchTranslateTextRequest, Sequence[Tuple[str, str]] + translation_service.BatchTranslateTextRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for batch_translate_text @@ -444,8 +456,11 @@ def post_batch_translate_text( def pre_create_adaptive_mt_dataset( self, request: adaptive_mt.CreateAdaptiveMtDatasetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[adaptive_mt.CreateAdaptiveMtDatasetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + adaptive_mt.CreateAdaptiveMtDatasetRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_adaptive_mt_dataset Override in a subclass to manipulate the request or metadata @@ -467,8 +482,10 @@ def post_create_adaptive_mt_dataset( def pre_create_dataset( self, request: automl_translation.CreateDatasetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[automl_translation.CreateDatasetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + automl_translation.CreateDatasetRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_dataset Override in a subclass to manipulate the request or metadata @@ -490,8 +507,11 @@ def post_create_dataset( def pre_create_glossary( self, request: translation_service.CreateGlossaryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.CreateGlossaryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.CreateGlossaryRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_glossary Override in a subclass to manipulate the request or metadata @@ -513,9 +533,10 @@ def post_create_glossary( def pre_create_glossary_entry( self, request: translation_service.CreateGlossaryEntryRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - translation_service.CreateGlossaryEntryRequest, Sequence[Tuple[str, str]] + translation_service.CreateGlossaryEntryRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_glossary_entry @@ -538,8 +559,10 @@ def post_create_glossary_entry( def pre_create_model( self, request: automl_translation.CreateModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[automl_translation.CreateModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + automl_translation.CreateModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_model Override in a subclass to manipulate the request or metadata @@ -561,8 +584,11 @@ def post_create_model( def pre_delete_adaptive_mt_dataset( self, request: adaptive_mt.DeleteAdaptiveMtDatasetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[adaptive_mt.DeleteAdaptiveMtDatasetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + adaptive_mt.DeleteAdaptiveMtDatasetRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_adaptive_mt_dataset Override in a subclass to manipulate the request or metadata @@ -573,8 +599,10 @@ def pre_delete_adaptive_mt_dataset( def pre_delete_adaptive_mt_file( self, request: adaptive_mt.DeleteAdaptiveMtFileRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[adaptive_mt.DeleteAdaptiveMtFileRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + adaptive_mt.DeleteAdaptiveMtFileRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_adaptive_mt_file Override in a subclass to manipulate the request or metadata @@ -585,8 +613,10 @@ def pre_delete_adaptive_mt_file( def pre_delete_dataset( self, request: automl_translation.DeleteDatasetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[automl_translation.DeleteDatasetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + automl_translation.DeleteDatasetRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_dataset Override in a subclass to manipulate the request or metadata @@ -608,8 +638,11 @@ def post_delete_dataset( def pre_delete_glossary( self, request: translation_service.DeleteGlossaryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.DeleteGlossaryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.DeleteGlossaryRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_glossary Override in a subclass to manipulate the request or metadata @@ -631,9 +664,10 @@ def post_delete_glossary( def pre_delete_glossary_entry( self, request: translation_service.DeleteGlossaryEntryRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - translation_service.DeleteGlossaryEntryRequest, Sequence[Tuple[str, str]] + translation_service.DeleteGlossaryEntryRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_glossary_entry @@ -645,8 +679,10 @@ def pre_delete_glossary_entry( def pre_delete_model( self, request: automl_translation.DeleteModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[automl_translation.DeleteModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + automl_translation.DeleteModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_model Override in a subclass to manipulate the request or metadata @@ -668,8 +704,11 @@ def post_delete_model( def pre_detect_language( self, request: translation_service.DetectLanguageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.DetectLanguageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.DetectLanguageRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for detect_language Override in a subclass to manipulate the request or metadata @@ -691,8 +730,10 @@ def post_detect_language( def pre_export_data( self, request: automl_translation.ExportDataRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[automl_translation.ExportDataRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + automl_translation.ExportDataRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for export_data Override in a subclass to manipulate the request or metadata @@ -714,8 +755,10 @@ def post_export_data( def pre_get_adaptive_mt_dataset( self, request: adaptive_mt.GetAdaptiveMtDatasetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[adaptive_mt.GetAdaptiveMtDatasetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + adaptive_mt.GetAdaptiveMtDatasetRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_adaptive_mt_dataset Override in a subclass to manipulate the request or metadata @@ -737,8 +780,10 @@ def post_get_adaptive_mt_dataset( def pre_get_adaptive_mt_file( self, request: adaptive_mt.GetAdaptiveMtFileRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[adaptive_mt.GetAdaptiveMtFileRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + adaptive_mt.GetAdaptiveMtFileRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_adaptive_mt_file Override in a subclass to manipulate the request or metadata @@ -760,8 +805,10 @@ def post_get_adaptive_mt_file( def pre_get_dataset( self, request: automl_translation.GetDatasetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[automl_translation.GetDatasetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + automl_translation.GetDatasetRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_dataset Override in a subclass to manipulate the request or metadata @@ -783,8 +830,10 @@ def post_get_dataset( def pre_get_glossary( self, request: translation_service.GetGlossaryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.GetGlossaryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.GetGlossaryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_glossary Override in a subclass to manipulate the request or metadata @@ -806,8 +855,11 @@ def post_get_glossary( def pre_get_glossary_entry( self, request: translation_service.GetGlossaryEntryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.GetGlossaryEntryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.GetGlossaryEntryRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_glossary_entry Override in a subclass to manipulate the request or metadata @@ -829,8 +881,10 @@ def post_get_glossary_entry( def pre_get_model( self, request: automl_translation.GetModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[automl_translation.GetModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + automl_translation.GetModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_model Override in a subclass to manipulate the request or metadata @@ -852,9 +906,10 @@ def post_get_model( def pre_get_supported_languages( self, request: translation_service.GetSupportedLanguagesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - translation_service.GetSupportedLanguagesRequest, Sequence[Tuple[str, str]] + translation_service.GetSupportedLanguagesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_supported_languages @@ -877,8 +932,10 @@ def post_get_supported_languages( def pre_import_adaptive_mt_file( self, request: adaptive_mt.ImportAdaptiveMtFileRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[adaptive_mt.ImportAdaptiveMtFileRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + adaptive_mt.ImportAdaptiveMtFileRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for import_adaptive_mt_file Override in a subclass to manipulate the request or metadata @@ -900,8 +957,10 @@ def post_import_adaptive_mt_file( def pre_import_data( self, request: automl_translation.ImportDataRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[automl_translation.ImportDataRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + automl_translation.ImportDataRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for import_data Override in a subclass to manipulate the request or metadata @@ -923,8 +982,11 @@ def post_import_data( def pre_list_adaptive_mt_datasets( self, request: adaptive_mt.ListAdaptiveMtDatasetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[adaptive_mt.ListAdaptiveMtDatasetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + adaptive_mt.ListAdaptiveMtDatasetsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_adaptive_mt_datasets Override in a subclass to manipulate the request or metadata @@ -946,8 +1008,10 @@ def post_list_adaptive_mt_datasets( def pre_list_adaptive_mt_files( self, request: adaptive_mt.ListAdaptiveMtFilesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[adaptive_mt.ListAdaptiveMtFilesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + adaptive_mt.ListAdaptiveMtFilesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_adaptive_mt_files Override in a subclass to manipulate the request or metadata @@ -969,8 +1033,11 @@ def post_list_adaptive_mt_files( def pre_list_adaptive_mt_sentences( self, request: adaptive_mt.ListAdaptiveMtSentencesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[adaptive_mt.ListAdaptiveMtSentencesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + adaptive_mt.ListAdaptiveMtSentencesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_adaptive_mt_sentences Override in a subclass to manipulate the request or metadata @@ -992,8 +1059,10 @@ def post_list_adaptive_mt_sentences( def pre_list_datasets( self, request: automl_translation.ListDatasetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[automl_translation.ListDatasetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + automl_translation.ListDatasetsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_datasets Override in a subclass to manipulate the request or metadata @@ -1015,8 +1084,10 @@ def post_list_datasets( def pre_list_examples( self, request: automl_translation.ListExamplesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[automl_translation.ListExamplesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + automl_translation.ListExamplesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_examples Override in a subclass to manipulate the request or metadata @@ -1038,8 +1109,11 @@ def post_list_examples( def pre_list_glossaries( self, request: translation_service.ListGlossariesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.ListGlossariesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.ListGlossariesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_glossaries Override in a subclass to manipulate the request or metadata @@ -1061,9 +1135,10 @@ def post_list_glossaries( def pre_list_glossary_entries( self, request: translation_service.ListGlossaryEntriesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - translation_service.ListGlossaryEntriesRequest, Sequence[Tuple[str, str]] + translation_service.ListGlossaryEntriesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_glossary_entries @@ -1086,8 +1161,10 @@ def post_list_glossary_entries( def pre_list_models( self, request: automl_translation.ListModelsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[automl_translation.ListModelsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + automl_translation.ListModelsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_models Override in a subclass to manipulate the request or metadata @@ -1109,8 +1186,10 @@ def post_list_models( def pre_romanize_text( self, request: translation_service.RomanizeTextRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.RomanizeTextRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.RomanizeTextRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for romanize_text Override in a subclass to manipulate the request or metadata @@ -1132,8 +1211,11 @@ def post_romanize_text( def pre_translate_document( self, request: translation_service.TranslateDocumentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.TranslateDocumentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.TranslateDocumentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for translate_document Override in a subclass to manipulate the request or metadata @@ -1155,8 +1237,11 @@ def post_translate_document( def pre_translate_text( self, request: translation_service.TranslateTextRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.TranslateTextRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.TranslateTextRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for translate_text Override in a subclass to manipulate the request or metadata @@ -1178,8 +1263,11 @@ def post_translate_text( def pre_update_glossary( self, request: translation_service.UpdateGlossaryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.UpdateGlossaryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.UpdateGlossaryRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_glossary Override in a subclass to manipulate the request or metadata @@ -1201,9 +1289,10 @@ def post_update_glossary( def pre_update_glossary_entry( self, request: translation_service.UpdateGlossaryEntryRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - translation_service.UpdateGlossaryEntryRequest, Sequence[Tuple[str, str]] + translation_service.UpdateGlossaryEntryRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_glossary_entry @@ -1226,8 +1315,10 @@ def post_update_glossary_entry( 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 @@ -1249,8 +1340,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 @@ -1272,8 +1365,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 @@ -1293,8 +1388,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 @@ -1314,8 +1411,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 @@ -1337,8 +1436,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 @@ -1360,8 +1461,10 @@ def post_list_operations( def pre_wait_operation( self, request: operations_pb2.WaitOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.WaitOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.WaitOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for wait_operation Override in a subclass to manipulate the request or metadata @@ -1564,7 +1667,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.AdaptiveMtTranslateResponse: r"""Call the adaptive mt translate method over HTTP. @@ -1575,8 +1678,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.adaptive_mt.AdaptiveMtTranslateResponse: @@ -1586,6 +1691,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseAdaptiveMtTranslate._get_http_options() ) + request, metadata = self._interceptor.pre_adaptive_mt_translate( request, metadata ) @@ -1602,6 +1708,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.AdaptiveMtTranslate", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "AdaptiveMtTranslate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._AdaptiveMtTranslate._get_response( @@ -1625,7 +1758,31 @@ def __call__( pb_resp = adaptive_mt.AdaptiveMtTranslateResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_adaptive_mt_translate(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = adaptive_mt.AdaptiveMtTranslateResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3.TranslationServiceClient.adaptive_mt_translate", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "AdaptiveMtTranslate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchTranslateDocument( @@ -1664,7 +1821,7 @@ 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 translate document method over HTTP. @@ -1674,8 +1831,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1688,6 +1847,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseBatchTranslateDocument._get_http_options() ) + request, metadata = self._interceptor.pre_batch_translate_document( request, metadata ) @@ -1704,6 +1864,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.BatchTranslateDocument", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "BatchTranslateDocument", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._BatchTranslateDocument._get_response( @@ -1725,7 +1912,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_translate_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.translation_v3.TranslationServiceClient.batch_translate_document", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "BatchTranslateDocument", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchTranslateText( @@ -1764,7 +1973,7 @@ 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 translate text method over HTTP. @@ -1774,8 +1983,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1788,6 +1999,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseBatchTranslateText._get_http_options() ) + request, metadata = self._interceptor.pre_batch_translate_text( request, metadata ) @@ -1804,6 +2016,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.BatchTranslateText", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "BatchTranslateText", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._BatchTranslateText._get_response( @@ -1825,7 +2064,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_translate_text(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3.TranslationServiceClient.batch_translate_text", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "BatchTranslateText", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateAdaptiveMtDataset( @@ -1864,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]]] = (), ) -> adaptive_mt.AdaptiveMtDataset: r"""Call the create adaptive mt dataset method over HTTP. @@ -1876,8 +2137,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.adaptive_mt.AdaptiveMtDataset: @@ -1887,6 +2150,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseCreateAdaptiveMtDataset._get_http_options() ) + request, metadata = self._interceptor.pre_create_adaptive_mt_dataset( request, metadata ) @@ -1903,6 +2167,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.CreateAdaptiveMtDataset", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "CreateAdaptiveMtDataset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._CreateAdaptiveMtDataset._get_response( @@ -1926,7 +2217,29 @@ def __call__( pb_resp = adaptive_mt.AdaptiveMtDataset.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_adaptive_mt_dataset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = adaptive_mt.AdaptiveMtDataset.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3.TranslationServiceClient.create_adaptive_mt_dataset", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "CreateAdaptiveMtDataset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateDataset( @@ -1965,7 +2278,7 @@ 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. @@ -1975,8 +2288,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1989,6 +2304,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseCreateDataset._get_http_options() ) + request, metadata = self._interceptor.pre_create_dataset(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseCreateDataset._get_transcoded_request( http_options, request @@ -2003,6 +2319,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.CreateDataset", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "CreateDataset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._CreateDataset._get_response( self._host, @@ -2022,7 +2365,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.translation_v3.TranslationServiceClient.create_dataset", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "CreateDataset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateGlossary( @@ -2061,7 +2426,7 @@ 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 glossary method over HTTP. @@ -2071,8 +2436,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2085,6 +2452,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseCreateGlossary._get_http_options() ) + request, metadata = self._interceptor.pre_create_glossary(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseCreateGlossary._get_transcoded_request( http_options, request @@ -2099,6 +2467,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.CreateGlossary", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "CreateGlossary", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._CreateGlossary._get_response( self._host, @@ -2118,7 +2513,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_glossary(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3.TranslationServiceClient.create_glossary", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "CreateGlossary", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateGlossaryEntry( @@ -2157,7 +2574,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.GlossaryEntry: r"""Call the create glossary entry method over HTTP. @@ -2168,8 +2585,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.common.GlossaryEntry: @@ -2181,6 +2600,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseCreateGlossaryEntry._get_http_options() ) + request, metadata = self._interceptor.pre_create_glossary_entry( request, metadata ) @@ -2197,6 +2617,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.CreateGlossaryEntry", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "CreateGlossaryEntry", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._CreateGlossaryEntry._get_response( @@ -2220,7 +2667,29 @@ def __call__( pb_resp = common.GlossaryEntry.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_glossary_entry(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common.GlossaryEntry.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3.TranslationServiceClient.create_glossary_entry", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "CreateGlossaryEntry", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateModel( @@ -2259,7 +2728,7 @@ 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. @@ -2269,8 +2738,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2283,6 +2754,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseCreateModel._get_http_options() ) + request, metadata = self._interceptor.pre_create_model(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseCreateModel._get_transcoded_request( http_options, request @@ -2297,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.CreateModel", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "CreateModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._CreateModel._get_response( self._host, @@ -2316,7 +2815,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.translation_v3.TranslationServiceClient.create_model", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "CreateModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAdaptiveMtDataset( @@ -2354,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]]] = (), ): r"""Call the delete adaptive mt dataset method over HTTP. @@ -2366,13 +2887,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 = ( _BaseTranslationServiceRestTransport._BaseDeleteAdaptiveMtDataset._get_http_options() ) + request, metadata = self._interceptor.pre_delete_adaptive_mt_dataset( request, metadata ) @@ -2385,6 +2909,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.DeleteAdaptiveMtDataset", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "DeleteAdaptiveMtDataset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._DeleteAdaptiveMtDataset._get_response( @@ -2437,7 +2988,7 @@ 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 adaptive mt file method over HTTP. @@ -2448,13 +2999,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 = ( _BaseTranslationServiceRestTransport._BaseDeleteAdaptiveMtFile._get_http_options() ) + request, metadata = self._interceptor.pre_delete_adaptive_mt_file( request, metadata ) @@ -2467,6 +3021,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.DeleteAdaptiveMtFile", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "DeleteAdaptiveMtFile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._DeleteAdaptiveMtFile._get_response( @@ -2519,7 +3100,7 @@ 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. @@ -2529,8 +3110,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2543,6 +3126,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseDeleteDataset._get_http_options() ) + request, metadata = self._interceptor.pre_delete_dataset(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseDeleteDataset._get_transcoded_request( http_options, request @@ -2553,6 +3137,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.DeleteDataset", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "DeleteDataset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._DeleteDataset._get_response( self._host, @@ -2571,7 +3182,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.translation_v3.TranslationServiceClient.delete_dataset", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "DeleteDataset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteGlossary( @@ -2609,7 +3242,7 @@ 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 glossary method over HTTP. @@ -2619,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: ~.operations_pb2.Operation: @@ -2633,6 +3268,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseDeleteGlossary._get_http_options() ) + request, metadata = self._interceptor.pre_delete_glossary(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseDeleteGlossary._get_transcoded_request( http_options, request @@ -2643,6 +3279,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.DeleteGlossary", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "DeleteGlossary", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._DeleteGlossary._get_response( self._host, @@ -2661,7 +3324,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_glossary(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3.TranslationServiceClient.delete_glossary", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "DeleteGlossary", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteGlossaryEntry( @@ -2699,7 +3384,7 @@ 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 glossary entry method over HTTP. @@ -2710,13 +3395,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 = ( _BaseTranslationServiceRestTransport._BaseDeleteGlossaryEntry._get_http_options() ) + request, metadata = self._interceptor.pre_delete_glossary_entry( request, metadata ) @@ -2729,6 +3417,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.DeleteGlossaryEntry", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "DeleteGlossaryEntry", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._DeleteGlossaryEntry._get_response( @@ -2781,7 +3496,7 @@ 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. @@ -2791,8 +3506,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2805,6 +3522,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseDeleteModel._get_http_options() ) + request, metadata = self._interceptor.pre_delete_model(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseDeleteModel._get_transcoded_request( http_options, request @@ -2815,6 +3533,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.DeleteModel", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "DeleteModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._DeleteModel._get_response( self._host, @@ -2833,7 +3578,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.translation_v3.TranslationServiceClient.delete_model", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "DeleteModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DetectLanguage( @@ -2872,7 +3639,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.DetectLanguageResponse: r"""Call the detect language method over HTTP. @@ -2883,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: ~.translation_service.DetectLanguageResponse: @@ -2896,6 +3665,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseDetectLanguage._get_http_options() ) + request, metadata = self._interceptor.pre_detect_language(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseDetectLanguage._get_transcoded_request( http_options, request @@ -2910,6 +3680,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.DetectLanguage", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "DetectLanguage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._DetectLanguage._get_response( self._host, @@ -2931,7 +3728,31 @@ def __call__( pb_resp = translation_service.DetectLanguageResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_detect_language(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + translation_service.DetectLanguageResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3.TranslationServiceClient.detect_language", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "DetectLanguage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ExportData( @@ -2969,7 +3790,7 @@ 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. @@ -2979,8 +3800,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2993,6 +3816,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseExportData._get_http_options() ) + request, metadata = self._interceptor.pre_export_data(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseExportData._get_transcoded_request( http_options, request @@ -3007,6 +3831,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.ExportData", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ExportData", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._ExportData._get_response( self._host, @@ -3026,7 +3877,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.translation_v3.TranslationServiceClient.export_data", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ExportData", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAdaptiveMtDataset( @@ -3064,7 +3937,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.AdaptiveMtDataset: r"""Call the get adaptive mt dataset method over HTTP. @@ -3075,8 +3948,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.adaptive_mt.AdaptiveMtDataset: @@ -3086,6 +3961,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseGetAdaptiveMtDataset._get_http_options() ) + request, metadata = self._interceptor.pre_get_adaptive_mt_dataset( request, metadata ) @@ -3098,6 +3974,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.GetAdaptiveMtDataset", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetAdaptiveMtDataset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._GetAdaptiveMtDataset._get_response( @@ -3120,7 +4023,29 @@ def __call__( pb_resp = adaptive_mt.AdaptiveMtDataset.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_adaptive_mt_dataset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = adaptive_mt.AdaptiveMtDataset.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3.TranslationServiceClient.get_adaptive_mt_dataset", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetAdaptiveMtDataset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAdaptiveMtFile( @@ -3158,7 +4083,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.AdaptiveMtFile: r"""Call the get adaptive mt file method over HTTP. @@ -3169,8 +4094,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.adaptive_mt.AdaptiveMtFile: @@ -3180,6 +4107,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseGetAdaptiveMtFile._get_http_options() ) + request, metadata = self._interceptor.pre_get_adaptive_mt_file( request, metadata ) @@ -3192,6 +4120,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.GetAdaptiveMtFile", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetAdaptiveMtFile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._GetAdaptiveMtFile._get_response( self._host, @@ -3212,7 +4167,29 @@ def __call__( pb_resp = adaptive_mt.AdaptiveMtFile.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_adaptive_mt_file(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = adaptive_mt.AdaptiveMtFile.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3.TranslationServiceClient.get_adaptive_mt_file", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetAdaptiveMtFile", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDataset( @@ -3249,7 +4226,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> automl_translation.Dataset: r"""Call the get dataset method over HTTP. @@ -3259,8 +4236,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.automl_translation.Dataset: @@ -3273,6 +4252,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseGetDataset._get_http_options() ) + request, metadata = self._interceptor.pre_get_dataset(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseGetDataset._get_transcoded_request( http_options, request @@ -3283,6 +4263,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.GetDataset", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetDataset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._GetDataset._get_response( self._host, @@ -3303,7 +4310,29 @@ def __call__( pb_resp = automl_translation.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 = automl_translation.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.translation_v3.TranslationServiceClient.get_dataset", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetDataset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetGlossary( @@ -3341,7 +4370,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.Glossary: r"""Call the get glossary method over HTTP. @@ -3351,8 +4380,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.translation_service.Glossary: @@ -3364,6 +4395,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseGetGlossary._get_http_options() ) + request, metadata = self._interceptor.pre_get_glossary(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseGetGlossary._get_transcoded_request( http_options, request @@ -3374,6 +4406,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.GetGlossary", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetGlossary", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._GetGlossary._get_response( self._host, @@ -3394,7 +4453,29 @@ def __call__( pb_resp = translation_service.Glossary.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_glossary(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = translation_service.Glossary.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3.TranslationServiceClient.get_glossary", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetGlossary", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetGlossaryEntry( @@ -3432,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]]] = (), ) -> common.GlossaryEntry: r"""Call the get glossary entry method over HTTP. @@ -3443,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: ~.common.GlossaryEntry: @@ -3456,6 +4539,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseGetGlossaryEntry._get_http_options() ) + request, metadata = self._interceptor.pre_get_glossary_entry( request, metadata ) @@ -3468,6 +4552,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.GetGlossaryEntry", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetGlossaryEntry", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._GetGlossaryEntry._get_response( self._host, @@ -3488,7 +4599,29 @@ def __call__( pb_resp = common.GlossaryEntry.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_glossary_entry(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common.GlossaryEntry.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3.TranslationServiceClient.get_glossary_entry", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetGlossaryEntry", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetModel( @@ -3525,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]]] = (), ) -> automl_translation.Model: r"""Call the get model method over HTTP. @@ -3535,8 +4668,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.automl_translation.Model: @@ -3546,6 +4681,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseGetModel._get_http_options() ) + request, metadata = self._interceptor.pre_get_model(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseGetModel._get_transcoded_request( http_options, request @@ -3556,6 +4692,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.GetModel", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._GetModel._get_response( self._host, @@ -3576,7 +4739,29 @@ def __call__( pb_resp = automl_translation.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 = automl_translation.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.translation_v3.TranslationServiceClient.get_model", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSupportedLanguages( @@ -3614,7 +4799,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.SupportedLanguages: r"""Call the get supported languages method over HTTP. @@ -3625,8 +4810,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.translation_service.SupportedLanguages: @@ -3638,6 +4825,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseGetSupportedLanguages._get_http_options() ) + request, metadata = self._interceptor.pre_get_supported_languages( request, metadata ) @@ -3650,6 +4838,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.GetSupportedLanguages", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetSupportedLanguages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._GetSupportedLanguages._get_response( @@ -3672,7 +4887,31 @@ def __call__( pb_resp = translation_service.SupportedLanguages.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_supported_languages(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = translation_service.SupportedLanguages.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3.TranslationServiceClient.get_supported_languages", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetSupportedLanguages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportAdaptiveMtFile( @@ -3711,7 +4950,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.ImportAdaptiveMtFileResponse: r"""Call the import adaptive mt file method over HTTP. @@ -3723,8 +4962,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.adaptive_mt.ImportAdaptiveMtFileResponse: @@ -3736,6 +4977,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseImportAdaptiveMtFile._get_http_options() ) + request, metadata = self._interceptor.pre_import_adaptive_mt_file( request, metadata ) @@ -3752,6 +4994,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.ImportAdaptiveMtFile", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ImportAdaptiveMtFile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._ImportAdaptiveMtFile._get_response( @@ -3775,7 +5044,31 @@ def __call__( pb_resp = adaptive_mt.ImportAdaptiveMtFileResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_adaptive_mt_file(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = adaptive_mt.ImportAdaptiveMtFileResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3.TranslationServiceClient.import_adaptive_mt_file", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ImportAdaptiveMtFile", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportData( @@ -3813,7 +5106,7 @@ 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. @@ -3823,8 +5116,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3837,6 +5132,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseImportData._get_http_options() ) + request, metadata = self._interceptor.pre_import_data(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseImportData._get_transcoded_request( http_options, request @@ -3851,6 +5147,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.ImportData", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ImportData", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._ImportData._get_response( self._host, @@ -3870,7 +5193,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.translation_v3.TranslationServiceClient.import_data", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ImportData", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAdaptiveMtDatasets( @@ -3908,7 +5253,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.ListAdaptiveMtDatasetsResponse: r"""Call the list adaptive mt datasets method over HTTP. @@ -3920,8 +5265,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.adaptive_mt.ListAdaptiveMtDatasetsResponse: @@ -3931,6 +5278,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseListAdaptiveMtDatasets._get_http_options() ) + request, metadata = self._interceptor.pre_list_adaptive_mt_datasets( request, metadata ) @@ -3943,6 +5291,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.ListAdaptiveMtDatasets", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListAdaptiveMtDatasets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._ListAdaptiveMtDatasets._get_response( @@ -3965,7 +5340,31 @@ def __call__( pb_resp = adaptive_mt.ListAdaptiveMtDatasetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_adaptive_mt_datasets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + adaptive_mt.ListAdaptiveMtDatasetsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3.TranslationServiceClient.list_adaptive_mt_datasets", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListAdaptiveMtDatasets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAdaptiveMtFiles( @@ -4003,7 +5402,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.ListAdaptiveMtFilesResponse: r"""Call the list adaptive mt files method over HTTP. @@ -4014,8 +5413,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.adaptive_mt.ListAdaptiveMtFilesResponse: @@ -4027,6 +5428,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseListAdaptiveMtFiles._get_http_options() ) + request, metadata = self._interceptor.pre_list_adaptive_mt_files( request, metadata ) @@ -4039,6 +5441,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.ListAdaptiveMtFiles", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListAdaptiveMtFiles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._ListAdaptiveMtFiles._get_response( @@ -4061,7 +5490,31 @@ def __call__( pb_resp = adaptive_mt.ListAdaptiveMtFilesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_adaptive_mt_files(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = adaptive_mt.ListAdaptiveMtFilesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3.TranslationServiceClient.list_adaptive_mt_files", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListAdaptiveMtFiles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAdaptiveMtSentences( @@ -4099,7 +5552,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.ListAdaptiveMtSentencesResponse: r"""Call the list adaptive mt sentences method over HTTP. @@ -4111,8 +5564,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.adaptive_mt.ListAdaptiveMtSentencesResponse: @@ -4122,6 +5577,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseListAdaptiveMtSentences._get_http_options() ) + request, metadata = self._interceptor.pre_list_adaptive_mt_sentences( request, metadata ) @@ -4134,6 +5590,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.ListAdaptiveMtSentences", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListAdaptiveMtSentences", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._ListAdaptiveMtSentences._get_response( @@ -4156,7 +5639,31 @@ def __call__( pb_resp = adaptive_mt.ListAdaptiveMtSentencesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_adaptive_mt_sentences(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + adaptive_mt.ListAdaptiveMtSentencesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3.TranslationServiceClient.list_adaptive_mt_sentences", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListAdaptiveMtSentences", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDatasets( @@ -4194,7 +5701,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> automl_translation.ListDatasetsResponse: r"""Call the list datasets method over HTTP. @@ -4204,8 +5711,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.automl_translation.ListDatasetsResponse: @@ -4215,6 +5724,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseListDatasets._get_http_options() ) + request, metadata = self._interceptor.pre_list_datasets(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseListDatasets._get_transcoded_request( http_options, request @@ -4225,6 +5735,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.ListDatasets", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListDatasets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._ListDatasets._get_response( self._host, @@ -4245,7 +5782,31 @@ def __call__( pb_resp = automl_translation.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 = automl_translation.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.translation_v3.TranslationServiceClient.list_datasets", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListDatasets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListExamples( @@ -4283,7 +5844,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> automl_translation.ListExamplesResponse: r"""Call the list examples method over HTTP. @@ -4293,8 +5854,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.automl_translation.ListExamplesResponse: @@ -4304,6 +5867,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseListExamples._get_http_options() ) + request, metadata = self._interceptor.pre_list_examples(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseListExamples._get_transcoded_request( http_options, request @@ -4314,6 +5878,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.ListExamples", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListExamples", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._ListExamples._get_response( self._host, @@ -4334,7 +5925,31 @@ def __call__( pb_resp = automl_translation.ListExamplesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_examples(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = automl_translation.ListExamplesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3.TranslationServiceClient.list_examples", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListExamples", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListGlossaries( @@ -4372,7 +5987,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.ListGlossariesResponse: r"""Call the list glossaries method over HTTP. @@ -4382,8 +5997,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.translation_service.ListGlossariesResponse: @@ -4393,6 +6010,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseListGlossaries._get_http_options() ) + request, metadata = self._interceptor.pre_list_glossaries(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseListGlossaries._get_transcoded_request( http_options, request @@ -4403,6 +6021,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.ListGlossaries", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListGlossaries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._ListGlossaries._get_response( self._host, @@ -4423,7 +6068,31 @@ def __call__( pb_resp = translation_service.ListGlossariesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_glossaries(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + translation_service.ListGlossariesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3.TranslationServiceClient.list_glossaries", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListGlossaries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListGlossaryEntries( @@ -4461,7 +6130,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.ListGlossaryEntriesResponse: r"""Call the list glossary entries method over HTTP. @@ -4472,8 +6141,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.translation_service.ListGlossaryEntriesResponse: @@ -4485,6 +6156,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseListGlossaryEntries._get_http_options() ) + request, metadata = self._interceptor.pre_list_glossary_entries( request, metadata ) @@ -4497,6 +6169,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.ListGlossaryEntries", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListGlossaryEntries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._ListGlossaryEntries._get_response( @@ -4519,7 +6218,33 @@ def __call__( pb_resp = translation_service.ListGlossaryEntriesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_glossary_entries(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + translation_service.ListGlossaryEntriesResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3.TranslationServiceClient.list_glossary_entries", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListGlossaryEntries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListModels( @@ -4556,7 +6281,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> automl_translation.ListModelsResponse: r"""Call the list models method over HTTP. @@ -4566,8 +6291,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.automl_translation.ListModelsResponse: @@ -4577,6 +6304,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseListModels._get_http_options() ) + request, metadata = self._interceptor.pre_list_models(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseListModels._get_transcoded_request( http_options, request @@ -4587,6 +6315,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.ListModels", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListModels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._ListModels._get_response( self._host, @@ -4607,7 +6362,31 @@ def __call__( pb_resp = automl_translation.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 = automl_translation.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.translation_v3.TranslationServiceClient.list_models", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListModels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RomanizeText( @@ -4646,7 +6425,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.RomanizeTextResponse: r"""Call the romanize text method over HTTP. @@ -4657,8 +6436,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.translation_service.RomanizeTextResponse: @@ -4670,6 +6451,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseRomanizeText._get_http_options() ) + request, metadata = self._interceptor.pre_romanize_text(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseRomanizeText._get_transcoded_request( http_options, request @@ -4684,6 +6466,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.RomanizeText", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "RomanizeText", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._RomanizeText._get_response( self._host, @@ -4705,7 +6514,31 @@ def __call__( pb_resp = translation_service.RomanizeTextResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_romanize_text(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = translation_service.RomanizeTextResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3.TranslationServiceClient.romanize_text", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "RomanizeText", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TranslateDocument( @@ -4744,7 +6577,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.TranslateDocumentResponse: r"""Call the translate document method over HTTP. @@ -4754,8 +6587,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.translation_service.TranslateDocumentResponse: @@ -4767,6 +6602,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseTranslateDocument._get_http_options() ) + request, metadata = self._interceptor.pre_translate_document( request, metadata ) @@ -4783,6 +6619,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.TranslateDocument", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "TranslateDocument", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._TranslateDocument._get_response( self._host, @@ -4804,7 +6667,31 @@ def __call__( pb_resp = translation_service.TranslateDocumentResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_translate_document(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + translation_service.TranslateDocumentResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3.TranslationServiceClient.translate_document", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "TranslateDocument", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TranslateText( @@ -4843,7 +6730,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.TranslateTextResponse: r"""Call the translate text method over HTTP. @@ -4854,8 +6741,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.translation_service.TranslateTextResponse: @@ -4865,6 +6754,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseTranslateText._get_http_options() ) + request, metadata = self._interceptor.pre_translate_text(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseTranslateText._get_transcoded_request( http_options, request @@ -4879,6 +6769,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.TranslateText", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "TranslateText", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._TranslateText._get_response( self._host, @@ -4900,7 +6817,31 @@ def __call__( pb_resp = translation_service.TranslateTextResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_translate_text(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + translation_service.TranslateTextResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3.TranslationServiceClient.translate_text", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "TranslateText", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateGlossary( @@ -4939,7 +6880,7 @@ 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 glossary method over HTTP. @@ -4950,8 +6891,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4964,6 +6907,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseUpdateGlossary._get_http_options() ) + request, metadata = self._interceptor.pre_update_glossary(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseUpdateGlossary._get_transcoded_request( http_options, request @@ -4978,6 +6922,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.UpdateGlossary", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "UpdateGlossary", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._UpdateGlossary._get_response( self._host, @@ -4997,7 +6968,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_glossary(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3.TranslationServiceClient.update_glossary", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "UpdateGlossary", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateGlossaryEntry( @@ -5036,7 +7029,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.GlossaryEntry: r"""Call the update glossary entry method over HTTP. @@ -5047,8 +7040,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.common.GlossaryEntry: @@ -5060,6 +7055,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseUpdateGlossaryEntry._get_http_options() ) + request, metadata = self._interceptor.pre_update_glossary_entry( request, metadata ) @@ -5076,6 +7072,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.UpdateGlossaryEntry", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "UpdateGlossaryEntry", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._UpdateGlossaryEntry._get_response( @@ -5099,7 +7122,29 @@ def __call__( pb_resp = common.GlossaryEntry.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_glossary_entry(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common.GlossaryEntry.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3.TranslationServiceClient.update_glossary_entry", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "UpdateGlossaryEntry", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -5509,7 +7554,7 @@ 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. @@ -5519,8 +7564,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -5529,6 +7576,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -5539,6 +7587,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._GetLocation._get_response( self._host, @@ -5558,6 +7633,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.translation_v3.TranslationServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5599,7 +7695,7 @@ 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. @@ -5609,8 +7705,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -5619,6 +7717,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -5629,6 +7728,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._ListLocations._get_response( self._host, @@ -5648,6 +7774,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.translation_v3.TranslationServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5690,7 +7837,7 @@ 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. @@ -5700,13 +7847,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 = ( _BaseTranslationServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -5723,6 +7873,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._CancelOperation._get_response( self._host, @@ -5780,7 +7957,7 @@ 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. @@ -5790,13 +7967,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 = ( _BaseTranslationServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -5809,6 +7989,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._DeleteOperation._get_response( self._host, @@ -5865,7 +8072,7 @@ 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. @@ -5875,8 +8082,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -5885,6 +8094,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -5895,6 +8105,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._GetOperation._get_response( self._host, @@ -5914,6 +8151,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.translation_v3.TranslationServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5955,7 +8213,7 @@ 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. @@ -5965,8 +8223,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -5975,6 +8235,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -5985,6 +8246,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._ListOperations._get_response( self._host, @@ -6004,6 +8292,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.translation_v3.TranslationServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -6046,7 +8355,7 @@ 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 wait operation method over HTTP. @@ -6056,8 +8365,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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 WaitOperation method. @@ -6066,6 +8377,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseWaitOperation._get_http_options() ) + request, metadata = self._interceptor.pre_wait_operation(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseWaitOperation._get_transcoded_request( http_options, request @@ -6080,6 +8392,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3.TranslationServiceClient.WaitOperation", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "WaitOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._WaitOperation._get_response( self._host, @@ -6100,6 +8439,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_wait_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.translation_v3.TranslationServiceAsyncClient.WaitOperation", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "WaitOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-translate/google/cloud/translate_v3beta1/gapic_version.py b/packages/google-cloud-translate/google/cloud/translate_v3beta1/gapic_version.py index 4138c894ea3a..558c8aab67c5 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3beta1/gapic_version.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.18.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/async_client.py b/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/async_client.py index 90e6d6aedc1b..87ea8f693701 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/async_client.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_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, TranslationServiceTransport from .transports.grpc_asyncio import TranslationServiceGrpcAsyncIOTransport +try: + from google.api_core import client_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 TranslationServiceAsyncClient: """Provides natural language translation operations.""" @@ -262,13 +272,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.translation_v3beta1.TranslationServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "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.translation.v3beta1.TranslationService", + "credentialsType": None, + }, + ) + async def translate_text( self, request: Optional[Union[translation_service.TranslateTextRequest, 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]]] = (), ) -> translation_service.TranslateTextResponse: r"""Translates input text and returns translated text. @@ -307,8 +339,10 @@ async def sample_translate_text(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3beta1.types.TranslateTextResponse: @@ -357,7 +391,7 @@ async def detect_language( mime_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]]] = (), ) -> translation_service.DetectLanguageResponse: r"""Detects the language of text within a request. @@ -438,8 +472,10 @@ async def sample_detect_language(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3beta1.types.DetectLanguageResponse: @@ -508,7 +544,7 @@ async def get_supported_languages( model: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.SupportedLanguages: r"""Returns a list of supported languages for translation. @@ -594,8 +630,10 @@ async def sample_get_supported_languages(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3beta1.types.SupportedLanguages: @@ -661,7 +699,7 @@ async def translate_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]]] = (), ) -> translation_service.TranslateDocumentResponse: r"""Translates documents in synchronous mode. @@ -702,8 +740,10 @@ async def sample_translate_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.translate_v3beta1.types.TranslateDocumentResponse: @@ -751,7 +791,7 @@ async def batch_translate_text( *, retry: OptionalRetry = gapic_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"""Translates a large volume of text in asynchronous batch mode. This function provides real-time output as @@ -810,8 +850,10 @@ async def sample_batch_translate_text(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -878,7 +920,7 @@ async def batch_translate_document( output_config: Optional[translation_service.BatchDocumentOutputConfig] = None, retry: OptionalRetry = gapic_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"""Translates a large volume of document in asynchronous batch mode. This function provides real-time output as @@ -992,8 +1034,10 @@ async def sample_batch_translate_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: @@ -1085,7 +1129,7 @@ async def create_glossary( glossary: Optional[translation_service.Glossary] = None, retry: OptionalRetry = gapic_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 glossary and returns the long-running operation. Returns NOT_FOUND, if the project doesn't exist. @@ -1140,8 +1184,10 @@ async def sample_create_glossary(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1218,7 +1264,7 @@ async def list_glossaries( 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.ListGlossariesAsyncPager: r"""Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. @@ -1298,8 +1344,10 @@ async def sample_list_glossaries(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3beta1.services.translation_service.pagers.ListGlossariesAsyncPager: @@ -1376,7 +1424,7 @@ async def get_glossary( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.Glossary: r"""Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist. @@ -1420,8 +1468,10 @@ async def sample_get_glossary(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3beta1.types.Glossary: @@ -1484,7 +1534,7 @@ async def delete_glossary( name: Optional[str] = None, retry: OptionalRetry = gapic_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 glossary, or cancels glossary construction if the glossary isn't created yet. Returns NOT_FOUND, if the glossary @@ -1533,8 +1583,10 @@ async def sample_delete_glossary(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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-translate/google/cloud/translate_v3beta1/services/translation_service/client.py b/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/client.py index a82059655567..fcbb0db03671 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/client.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_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 timestamp_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( @@ -652,13 +666,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.translation_v3beta1.TranslationServiceClient`.", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "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.translation.v3beta1.TranslationService", + "credentialsType": None, + }, + ) + def translate_text( self, request: Optional[Union[translation_service.TranslateTextRequest, 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]]] = (), ) -> translation_service.TranslateTextResponse: r"""Translates input text and returns translated text. @@ -697,8 +734,10 @@ def sample_translate_text(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3beta1.types.TranslateTextResponse: @@ -745,7 +784,7 @@ def detect_language( mime_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]]] = (), ) -> translation_service.DetectLanguageResponse: r"""Detects the language of text within a request. @@ -826,8 +865,10 @@ def sample_detect_language(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3beta1.types.DetectLanguageResponse: @@ -893,7 +934,7 @@ def get_supported_languages( model: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.SupportedLanguages: r"""Returns a list of supported languages for translation. @@ -979,8 +1020,10 @@ def sample_get_supported_languages(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3beta1.types.SupportedLanguages: @@ -1043,7 +1086,7 @@ def translate_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]]] = (), ) -> translation_service.TranslateDocumentResponse: r"""Translates documents in synchronous mode. @@ -1084,8 +1127,10 @@ def sample_translate_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.translate_v3beta1.types.TranslateDocumentResponse: @@ -1131,7 +1176,7 @@ def batch_translate_text( *, retry: OptionalRetry = gapic_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"""Translates a large volume of text in asynchronous batch mode. This function provides real-time output as @@ -1190,8 +1235,10 @@ def sample_batch_translate_text(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1256,7 +1303,7 @@ def batch_translate_document( output_config: Optional[translation_service.BatchDocumentOutputConfig] = None, retry: OptionalRetry = gapic_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"""Translates a large volume of document in asynchronous batch mode. This function provides real-time output as @@ -1370,8 +1417,10 @@ def sample_batch_translate_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: @@ -1460,7 +1509,7 @@ def create_glossary( glossary: Optional[translation_service.Glossary] = None, retry: OptionalRetry = gapic_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 glossary and returns the long-running operation. Returns NOT_FOUND, if the project doesn't exist. @@ -1515,8 +1564,10 @@ def sample_create_glossary(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1590,7 +1641,7 @@ def list_glossaries( 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.ListGlossariesPager: r"""Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. @@ -1670,8 +1721,10 @@ def sample_list_glossaries(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3beta1.services.translation_service.pagers.ListGlossariesPager: @@ -1745,7 +1798,7 @@ def get_glossary( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.Glossary: r"""Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist. @@ -1789,8 +1842,10 @@ def sample_get_glossary(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.translate_v3beta1.types.Glossary: @@ -1850,7 +1905,7 @@ def delete_glossary( name: Optional[str] = None, retry: OptionalRetry = gapic_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 glossary, or cancels glossary construction if the glossary isn't created yet. Returns NOT_FOUND, if the glossary @@ -1899,8 +1954,10 @@ def sample_delete_glossary(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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-translate/google/cloud/translate_v3beta1/services/translation_service/pagers.py b/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/pagers.py index c342b99c761f..e84e8513b2ab 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/pagers.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_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 = translation_service.ListGlossariesRequest(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 = translation_service.ListGlossariesRequest(request) diff --git a/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/transports/grpc.py b/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/transports/grpc.py index c6e97a27fbbb..2bc75b6443a7 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/transports/grpc.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_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.translate_v3beta1.types import translation_service from .base import DEFAULT_CLIENT_INFO, TranslationServiceTransport +try: + from google.api_core import client_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.translation.v3beta1.TranslationService", + "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.translation.v3beta1.TranslationService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TranslationServiceGrpcTransport(TranslationServiceTransport): """gRPC backend transport for TranslationService. @@ -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 @@ -245,7 +331,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 translate_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "translate_text" not in self._stubs: - self._stubs["translate_text"] = self.grpc_channel.unary_unary( + self._stubs["translate_text"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/TranslateText", request_serializer=translation_service.TranslateTextRequest.serialize, response_deserializer=translation_service.TranslateTextResponse.deserialize, @@ -301,7 +389,7 @@ def detect_language( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "detect_language" not in self._stubs: - self._stubs["detect_language"] = self.grpc_channel.unary_unary( + self._stubs["detect_language"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/DetectLanguage", request_serializer=translation_service.DetectLanguageRequest.serialize, response_deserializer=translation_service.DetectLanguageResponse.deserialize, @@ -331,7 +419,7 @@ def get_supported_languages( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_supported_languages" not in self._stubs: - self._stubs["get_supported_languages"] = self.grpc_channel.unary_unary( + self._stubs["get_supported_languages"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/GetSupportedLanguages", request_serializer=translation_service.GetSupportedLanguagesRequest.serialize, response_deserializer=translation_service.SupportedLanguages.deserialize, @@ -360,7 +448,7 @@ def translate_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "translate_document" not in self._stubs: - self._stubs["translate_document"] = self.grpc_channel.unary_unary( + self._stubs["translate_document"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/TranslateDocument", request_serializer=translation_service.TranslateDocumentRequest.serialize, response_deserializer=translation_service.TranslateDocumentResponse.deserialize, @@ -397,7 +485,7 @@ def batch_translate_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_translate_text" not in self._stubs: - self._stubs["batch_translate_text"] = self.grpc_channel.unary_unary( + self._stubs["batch_translate_text"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/BatchTranslateText", request_serializer=translation_service.BatchTranslateTextRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -434,7 +522,7 @@ def batch_translate_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_translate_document" not in self._stubs: - self._stubs["batch_translate_document"] = self.grpc_channel.unary_unary( + self._stubs["batch_translate_document"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/BatchTranslateDocument", request_serializer=translation_service.BatchTranslateDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -463,7 +551,7 @@ def create_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_glossary" not in self._stubs: - self._stubs["create_glossary"] = self.grpc_channel.unary_unary( + self._stubs["create_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/CreateGlossary", request_serializer=translation_service.CreateGlossaryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -493,7 +581,7 @@ def list_glossaries( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_glossaries" not in self._stubs: - self._stubs["list_glossaries"] = self.grpc_channel.unary_unary( + self._stubs["list_glossaries"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/ListGlossaries", request_serializer=translation_service.ListGlossariesRequest.serialize, response_deserializer=translation_service.ListGlossariesResponse.deserialize, @@ -522,7 +610,7 @@ def get_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_glossary" not in self._stubs: - self._stubs["get_glossary"] = self.grpc_channel.unary_unary( + self._stubs["get_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/GetGlossary", request_serializer=translation_service.GetGlossaryRequest.serialize, response_deserializer=translation_service.Glossary.deserialize, @@ -552,7 +640,7 @@ def delete_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_glossary" not in self._stubs: - self._stubs["delete_glossary"] = self.grpc_channel.unary_unary( + self._stubs["delete_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/DeleteGlossary", request_serializer=translation_service.DeleteGlossaryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -560,7 +648,7 @@ def delete_glossary( return self._stubs["delete_glossary"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/transports/grpc_asyncio.py b/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/transports/grpc_asyncio.py index 61c06d644a1e..1550048e656b 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_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.translate_v3beta1.types import translation_service from .base import DEFAULT_CLIENT_INFO, TranslationServiceTransport from .grpc import TranslationServiceGrpcTransport +try: + from google.api_core import client_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.translation.v3beta1.TranslationService", + "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.translation.v3beta1.TranslationService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TranslationServiceGrpcAsyncIOTransport(TranslationServiceTransport): """gRPC AsyncIO backend transport for TranslationService. @@ -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 @@ -254,7 +339,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 translate_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "translate_text" not in self._stubs: - self._stubs["translate_text"] = self.grpc_channel.unary_unary( + self._stubs["translate_text"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/TranslateText", request_serializer=translation_service.TranslateTextRequest.serialize, response_deserializer=translation_service.TranslateTextResponse.deserialize, @@ -311,7 +396,7 @@ def detect_language( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "detect_language" not in self._stubs: - self._stubs["detect_language"] = self.grpc_channel.unary_unary( + self._stubs["detect_language"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/DetectLanguage", request_serializer=translation_service.DetectLanguageRequest.serialize, response_deserializer=translation_service.DetectLanguageResponse.deserialize, @@ -341,7 +426,7 @@ def get_supported_languages( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_supported_languages" not in self._stubs: - self._stubs["get_supported_languages"] = self.grpc_channel.unary_unary( + self._stubs["get_supported_languages"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/GetSupportedLanguages", request_serializer=translation_service.GetSupportedLanguagesRequest.serialize, response_deserializer=translation_service.SupportedLanguages.deserialize, @@ -370,7 +455,7 @@ def translate_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "translate_document" not in self._stubs: - self._stubs["translate_document"] = self.grpc_channel.unary_unary( + self._stubs["translate_document"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/TranslateDocument", request_serializer=translation_service.TranslateDocumentRequest.serialize, response_deserializer=translation_service.TranslateDocumentResponse.deserialize, @@ -408,7 +493,7 @@ def batch_translate_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_translate_text" not in self._stubs: - self._stubs["batch_translate_text"] = self.grpc_channel.unary_unary( + self._stubs["batch_translate_text"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/BatchTranslateText", request_serializer=translation_service.BatchTranslateTextRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -446,7 +531,7 @@ def batch_translate_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_translate_document" not in self._stubs: - self._stubs["batch_translate_document"] = self.grpc_channel.unary_unary( + self._stubs["batch_translate_document"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/BatchTranslateDocument", request_serializer=translation_service.BatchTranslateDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -475,7 +560,7 @@ def create_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_glossary" not in self._stubs: - self._stubs["create_glossary"] = self.grpc_channel.unary_unary( + self._stubs["create_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/CreateGlossary", request_serializer=translation_service.CreateGlossaryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -505,7 +590,7 @@ def list_glossaries( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_glossaries" not in self._stubs: - self._stubs["list_glossaries"] = self.grpc_channel.unary_unary( + self._stubs["list_glossaries"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/ListGlossaries", request_serializer=translation_service.ListGlossariesRequest.serialize, response_deserializer=translation_service.ListGlossariesResponse.deserialize, @@ -535,7 +620,7 @@ def get_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_glossary" not in self._stubs: - self._stubs["get_glossary"] = self.grpc_channel.unary_unary( + self._stubs["get_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/GetGlossary", request_serializer=translation_service.GetGlossaryRequest.serialize, response_deserializer=translation_service.Glossary.deserialize, @@ -565,7 +650,7 @@ def delete_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_glossary" not in self._stubs: - self._stubs["delete_glossary"] = self.grpc_channel.unary_unary( + self._stubs["delete_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/DeleteGlossary", request_serializer=translation_service.DeleteGlossaryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -673,7 +758,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-translate/google/cloud/translate_v3beta1/services/translation_service/transports/rest.py b/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/transports/rest.py index 3e82d1fbd473..c50e7729fd8d 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/transports/rest.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_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, @@ -150,9 +158,10 @@ def post_translate_text(self, response): def pre_batch_translate_document( self, request: translation_service.BatchTranslateDocumentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - translation_service.BatchTranslateDocumentRequest, Sequence[Tuple[str, str]] + translation_service.BatchTranslateDocumentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for batch_translate_document @@ -175,9 +184,10 @@ def post_batch_translate_document( def pre_batch_translate_text( self, request: translation_service.BatchTranslateTextRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - translation_service.BatchTranslateTextRequest, Sequence[Tuple[str, str]] + translation_service.BatchTranslateTextRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for batch_translate_text @@ -200,8 +210,11 @@ def post_batch_translate_text( def pre_create_glossary( self, request: translation_service.CreateGlossaryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.CreateGlossaryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.CreateGlossaryRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_glossary Override in a subclass to manipulate the request or metadata @@ -223,8 +236,11 @@ def post_create_glossary( def pre_delete_glossary( self, request: translation_service.DeleteGlossaryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.DeleteGlossaryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.DeleteGlossaryRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_glossary Override in a subclass to manipulate the request or metadata @@ -246,8 +262,11 @@ def post_delete_glossary( def pre_detect_language( self, request: translation_service.DetectLanguageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.DetectLanguageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.DetectLanguageRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for detect_language Override in a subclass to manipulate the request or metadata @@ -269,8 +288,10 @@ def post_detect_language( def pre_get_glossary( self, request: translation_service.GetGlossaryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.GetGlossaryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.GetGlossaryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_glossary Override in a subclass to manipulate the request or metadata @@ -292,9 +313,10 @@ def post_get_glossary( def pre_get_supported_languages( self, request: translation_service.GetSupportedLanguagesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - translation_service.GetSupportedLanguagesRequest, Sequence[Tuple[str, str]] + translation_service.GetSupportedLanguagesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_supported_languages @@ -317,8 +339,11 @@ def post_get_supported_languages( def pre_list_glossaries( self, request: translation_service.ListGlossariesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.ListGlossariesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.ListGlossariesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_glossaries Override in a subclass to manipulate the request or metadata @@ -340,8 +365,11 @@ def post_list_glossaries( def pre_translate_document( self, request: translation_service.TranslateDocumentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.TranslateDocumentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.TranslateDocumentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for translate_document Override in a subclass to manipulate the request or metadata @@ -363,8 +391,11 @@ def post_translate_document( def pre_translate_text( self, request: translation_service.TranslateTextRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.TranslateTextRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.TranslateTextRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for translate_text Override in a subclass to manipulate the request or metadata @@ -567,7 +598,7 @@ 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 translate document method over HTTP. @@ -577,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: ~.operations_pb2.Operation: @@ -591,6 +624,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseBatchTranslateDocument._get_http_options() ) + request, metadata = self._interceptor.pre_batch_translate_document( request, metadata ) @@ -607,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3beta1.TranslationServiceClient.BatchTranslateDocument", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "BatchTranslateDocument", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._BatchTranslateDocument._get_response( @@ -628,7 +689,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_translate_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.translation_v3beta1.TranslationServiceClient.batch_translate_document", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "BatchTranslateDocument", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchTranslateText( @@ -667,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 batch translate text method over HTTP. @@ -677,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: ~.operations_pb2.Operation: @@ -691,6 +776,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseBatchTranslateText._get_http_options() ) + request, metadata = self._interceptor.pre_batch_translate_text( request, metadata ) @@ -707,6 +793,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3beta1.TranslationServiceClient.BatchTranslateText", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "BatchTranslateText", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._BatchTranslateText._get_response( @@ -728,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_batch_translate_text(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3beta1.TranslationServiceClient.batch_translate_text", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "BatchTranslateText", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateGlossary( @@ -767,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create glossary method over HTTP. @@ -777,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: ~.operations_pb2.Operation: @@ -791,6 +928,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseCreateGlossary._get_http_options() ) + request, metadata = self._interceptor.pre_create_glossary(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseCreateGlossary._get_transcoded_request( http_options, request @@ -805,6 +943,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3beta1.TranslationServiceClient.CreateGlossary", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "CreateGlossary", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._CreateGlossary._get_response( self._host, @@ -824,7 +989,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_glossary(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3beta1.TranslationServiceClient.create_glossary", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "CreateGlossary", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteGlossary( @@ -862,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete glossary method over HTTP. @@ -872,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: ~.operations_pb2.Operation: @@ -886,6 +1075,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseDeleteGlossary._get_http_options() ) + request, metadata = self._interceptor.pre_delete_glossary(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseDeleteGlossary._get_transcoded_request( http_options, request @@ -896,6 +1086,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3beta1.TranslationServiceClient.DeleteGlossary", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "DeleteGlossary", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._DeleteGlossary._get_response( self._host, @@ -914,7 +1131,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_glossary(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3beta1.TranslationServiceClient.delete_glossary", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "DeleteGlossary", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DetectLanguage( @@ -953,7 +1192,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.DetectLanguageResponse: r"""Call the detect language method over HTTP. @@ -964,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: ~.translation_service.DetectLanguageResponse: @@ -977,6 +1218,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseDetectLanguage._get_http_options() ) + request, metadata = self._interceptor.pre_detect_language(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseDetectLanguage._get_transcoded_request( http_options, request @@ -991,6 +1233,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3beta1.TranslationServiceClient.DetectLanguage", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "DetectLanguage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._DetectLanguage._get_response( self._host, @@ -1012,7 +1281,31 @@ def __call__( pb_resp = translation_service.DetectLanguageResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_detect_language(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + translation_service.DetectLanguageResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3beta1.TranslationServiceClient.detect_language", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "DetectLanguage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetGlossary( @@ -1050,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]]] = (), ) -> translation_service.Glossary: r"""Call the get glossary method over HTTP. @@ -1060,8 +1353,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.translation_service.Glossary: @@ -1073,6 +1368,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseGetGlossary._get_http_options() ) + request, metadata = self._interceptor.pre_get_glossary(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseGetGlossary._get_transcoded_request( http_options, request @@ -1083,6 +1379,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3beta1.TranslationServiceClient.GetGlossary", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "GetGlossary", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._GetGlossary._get_response( self._host, @@ -1103,7 +1426,29 @@ def __call__( pb_resp = translation_service.Glossary.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_glossary(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = translation_service.Glossary.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3beta1.TranslationServiceClient.get_glossary", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "GetGlossary", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSupportedLanguages( @@ -1141,7 +1486,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.SupportedLanguages: r"""Call the get supported languages method over HTTP. @@ -1152,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: ~.translation_service.SupportedLanguages: @@ -1165,6 +1512,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseGetSupportedLanguages._get_http_options() ) + request, metadata = self._interceptor.pre_get_supported_languages( request, metadata ) @@ -1177,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 = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3beta1.TranslationServiceClient.GetSupportedLanguages", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "GetSupportedLanguages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._GetSupportedLanguages._get_response( @@ -1199,7 +1574,31 @@ def __call__( pb_resp = translation_service.SupportedLanguages.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_supported_languages(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = translation_service.SupportedLanguages.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3beta1.TranslationServiceClient.get_supported_languages", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "GetSupportedLanguages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListGlossaries( @@ -1237,7 +1636,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.ListGlossariesResponse: r"""Call the list glossaries method over HTTP. @@ -1247,8 +1646,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.translation_service.ListGlossariesResponse: @@ -1258,6 +1659,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseListGlossaries._get_http_options() ) + request, metadata = self._interceptor.pre_list_glossaries(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseListGlossaries._get_transcoded_request( http_options, request @@ -1268,6 +1670,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3beta1.TranslationServiceClient.ListGlossaries", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "ListGlossaries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._ListGlossaries._get_response( self._host, @@ -1288,7 +1717,31 @@ def __call__( pb_resp = translation_service.ListGlossariesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_glossaries(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + translation_service.ListGlossariesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3beta1.TranslationServiceClient.list_glossaries", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "ListGlossaries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TranslateDocument( @@ -1327,7 +1780,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.TranslateDocumentResponse: r"""Call the translate document method over HTTP. @@ -1337,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: ~.translation_service.TranslateDocumentResponse: @@ -1350,6 +1805,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseTranslateDocument._get_http_options() ) + request, metadata = self._interceptor.pre_translate_document( request, metadata ) @@ -1366,6 +1822,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3beta1.TranslationServiceClient.TranslateDocument", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "TranslateDocument", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._TranslateDocument._get_response( self._host, @@ -1387,7 +1870,31 @@ def __call__( pb_resp = translation_service.TranslateDocumentResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_translate_document(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + translation_service.TranslateDocumentResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3beta1.TranslationServiceClient.translate_document", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "TranslateDocument", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TranslateText( @@ -1426,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]]] = (), ) -> translation_service.TranslateTextResponse: r"""Call the translate text method over HTTP. @@ -1437,8 +1944,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.translation_service.TranslateTextResponse: @@ -1448,6 +1957,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseTranslateText._get_http_options() ) + request, metadata = self._interceptor.pre_translate_text(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseTranslateText._get_transcoded_request( http_options, request @@ -1462,6 +1972,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.translation_v3beta1.TranslationServiceClient.TranslateText", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "TranslateText", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._TranslateText._get_response( self._host, @@ -1483,7 +2020,31 @@ def __call__( pb_resp = translation_service.TranslateTextResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_translate_text(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + translation_service.TranslateTextResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.translation_v3beta1.TranslationServiceClient.translate_text", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "TranslateText", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-translate/samples/generated_samples/snippet_metadata_google.cloud.translation.v3.json b/packages/google-cloud-translate/samples/generated_samples/snippet_metadata_google.cloud.translation.v3.json index f8751bf48e01..de406536e428 100644 --- a/packages/google-cloud-translate/samples/generated_samples/snippet_metadata_google.cloud.translation.v3.json +++ b/packages/google-cloud-translate/samples/generated_samples/snippet_metadata_google.cloud.translation.v3.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-translate", - "version": "3.18.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.cloud.translate_v3.types.AdaptiveMtTranslateResponse", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.AdaptiveMtTranslateResponse", @@ -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", @@ -328,7 +328,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -405,7 +405,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", @@ -566,7 +566,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.AdaptiveMtDataset", @@ -650,7 +650,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.AdaptiveMtDataset", @@ -735,7 +735,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -819,7 +819,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -904,7 +904,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.GlossaryEntry", @@ -988,7 +988,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.GlossaryEntry", @@ -1073,7 +1073,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1157,7 +1157,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1242,7 +1242,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1326,7 +1326,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1407,7 +1407,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_adaptive_mt_dataset" @@ -1484,7 +1484,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_adaptive_mt_dataset" @@ -1562,7 +1562,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_adaptive_mt_file" @@ -1639,7 +1639,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_adaptive_mt_file" @@ -1717,7 +1717,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1797,7 +1797,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1878,7 +1878,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_glossary_entry" @@ -1955,7 +1955,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_glossary_entry" @@ -2033,7 +2033,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2113,7 +2113,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2194,7 +2194,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2274,7 +2274,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2367,7 +2367,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.DetectLanguageResponse", @@ -2459,7 +2459,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.DetectLanguageResponse", @@ -2544,7 +2544,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2628,7 +2628,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2709,7 +2709,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.AdaptiveMtDataset", @@ -2789,7 +2789,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.AdaptiveMtDataset", @@ -2870,7 +2870,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.AdaptiveMtFile", @@ -2950,7 +2950,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.AdaptiveMtFile", @@ -3031,7 +3031,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.Dataset", @@ -3111,7 +3111,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.Dataset", @@ -3192,7 +3192,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.GlossaryEntry", @@ -3272,7 +3272,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.GlossaryEntry", @@ -3353,7 +3353,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.Glossary", @@ -3433,7 +3433,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.Glossary", @@ -3514,7 +3514,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.Model", @@ -3594,7 +3594,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.Model", @@ -3683,7 +3683,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.SupportedLanguages", @@ -3771,7 +3771,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.SupportedLanguages", @@ -3852,7 +3852,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.ImportAdaptiveMtFileResponse", @@ -3932,7 +3932,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.ImportAdaptiveMtFileResponse", @@ -4017,7 +4017,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4101,7 +4101,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4182,7 +4182,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListAdaptiveMtDatasetsAsyncPager", @@ -4262,7 +4262,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListAdaptiveMtDatasetsPager", @@ -4343,7 +4343,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListAdaptiveMtFilesAsyncPager", @@ -4423,7 +4423,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListAdaptiveMtFilesPager", @@ -4504,7 +4504,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListAdaptiveMtSentencesAsyncPager", @@ -4584,7 +4584,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListAdaptiveMtSentencesPager", @@ -4665,7 +4665,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListDatasetsAsyncPager", @@ -4745,7 +4745,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListDatasetsPager", @@ -4826,7 +4826,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListExamplesAsyncPager", @@ -4906,7 +4906,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListExamplesPager", @@ -4987,7 +4987,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListGlossariesAsyncPager", @@ -5067,7 +5067,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListGlossariesPager", @@ -5148,7 +5148,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListGlossaryEntriesAsyncPager", @@ -5228,7 +5228,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListGlossaryEntriesPager", @@ -5309,7 +5309,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListModelsAsyncPager", @@ -5389,7 +5389,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListModelsPager", @@ -5474,7 +5474,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.RomanizeTextResponse", @@ -5558,7 +5558,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.RomanizeTextResponse", @@ -5635,7 +5635,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.TranslateDocumentResponse", @@ -5711,7 +5711,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.TranslateDocumentResponse", @@ -5812,7 +5812,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.TranslateTextResponse", @@ -5912,7 +5912,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.TranslateTextResponse", @@ -5993,7 +5993,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.GlossaryEntry", @@ -6073,7 +6073,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.GlossaryEntry", @@ -6158,7 +6158,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6242,7 +6242,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-translate/samples/generated_samples/snippet_metadata_google.cloud.translation.v3beta1.json b/packages/google-cloud-translate/samples/generated_samples/snippet_metadata_google.cloud.translation.v3beta1.json index c9f4757e0b92..74f2e4c9def9 100644 --- a/packages/google-cloud-translate/samples/generated_samples/snippet_metadata_google.cloud.translation.v3beta1.json +++ b/packages/google-cloud-translate/samples/generated_samples/snippet_metadata_google.cloud.translation.v3beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-translate", - "version": "3.18.0" + "version": "0.1.0" }, "snippets": [ { @@ -63,7 +63,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -159,7 +159,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -236,7 +236,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", @@ -397,7 +397,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", @@ -731,7 +731,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3beta1.types.DetectLanguageResponse", @@ -819,7 +819,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3beta1.types.DetectLanguageResponse", @@ -900,7 +900,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3beta1.types.Glossary", @@ -980,7 +980,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3beta1.types.Glossary", @@ -1069,7 +1069,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3beta1.types.SupportedLanguages", @@ -1157,7 +1157,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3beta1.types.SupportedLanguages", @@ -1242,7 +1242,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3beta1.services.translation_service.pagers.ListGlossariesAsyncPager", @@ -1326,7 +1326,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3beta1.services.translation_service.pagers.ListGlossariesPager", @@ -1403,7 +1403,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3beta1.types.TranslateDocumentResponse", @@ -1479,7 +1479,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3beta1.types.TranslateDocumentResponse", @@ -1556,7 +1556,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3beta1.types.TranslateTextResponse", @@ -1632,7 +1632,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3beta1.types.TranslateTextResponse", diff --git a/packages/google-cloud-translate/tests/unit/gapic/translate_v3/test_translation_service.py b/packages/google-cloud-translate/tests/unit/gapic/translate_v3/test_translation_service.py index c775b26efdcd..b52b06c732f8 100644 --- a/packages/google-cloud-translate/tests/unit/gapic/translate_v3/test_translation_service.py +++ b/packages/google-cloud-translate/tests/unit/gapic/translate_v3/test_translation_service.py @@ -15794,6 +15794,7 @@ def test_translate_text_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.translate_text(request) @@ -15853,6 +15854,7 @@ def test_translate_text_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.translate_text(**mock_args) @@ -15994,6 +15996,7 @@ def test_romanize_text_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.romanize_text(request) @@ -16048,6 +16051,7 @@ def test_romanize_text_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.romanize_text(**mock_args) @@ -16181,6 +16185,7 @@ def test_detect_language_rest_required_fields( response_value._content = json_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_language(request) @@ -16228,6 +16233,7 @@ def test_detect_language_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_language(**mock_args) @@ -16374,6 +16380,7 @@ def test_get_supported_languages_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_supported_languages(request) @@ -16429,6 +16436,7 @@ def test_get_supported_languages_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_supported_languages(**mock_args) @@ -16573,6 +16581,7 @@ def test_translate_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.translate_document(request) @@ -16715,6 +16724,7 @@ def test_batch_translate_text_rest_required_fields( response_value._content = json_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_translate_text(request) @@ -16860,6 +16870,7 @@ def test_batch_translate_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.batch_translate_document(request) @@ -16928,6 +16939,7 @@ def test_batch_translate_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.batch_translate_document(**mock_args) @@ -17075,6 +17087,7 @@ def test_create_glossary_rest_required_fields( response_value._content = json_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_glossary(request) @@ -17127,6 +17140,7 @@ def test_create_glossary_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_glossary(**mock_args) @@ -17257,6 +17271,7 @@ def test_update_glossary_rest_required_fields( response_value._content = json_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_glossary(request) @@ -17305,6 +17320,7 @@ def test_update_glossary_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_glossary(**mock_args) @@ -17445,6 +17461,7 @@ def test_list_glossaries_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_glossaries(request) @@ -17499,6 +17516,7 @@ def test_list_glossaries_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_glossaries(**mock_args) @@ -17692,6 +17710,7 @@ def test_get_glossary_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_glossary(request) @@ -17739,6 +17758,7 @@ def test_get_glossary_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_glossary(**mock_args) @@ -17870,6 +17890,7 @@ def test_delete_glossary_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_glossary(request) @@ -17915,6 +17936,7 @@ def test_delete_glossary_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_glossary(**mock_args) @@ -18049,6 +18071,7 @@ def test_get_glossary_entry_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_glossary_entry(request) @@ -18096,6 +18119,7 @@ def test_get_glossary_entry_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_glossary_entry(**mock_args) @@ -18241,6 +18265,7 @@ def test_list_glossary_entries_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_glossary_entries(request) @@ -18296,6 +18321,7 @@ def test_list_glossary_entries_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_glossary_entries(**mock_args) @@ -18498,6 +18524,7 @@ def test_create_glossary_entry_rest_required_fields( response_value._content = json_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_glossary_entry(request) @@ -18554,6 +18581,7 @@ def test_create_glossary_entry_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_glossary_entry(**mock_args) @@ -18687,6 +18715,7 @@ def test_update_glossary_entry_rest_required_fields( response_value._content = json_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_glossary_entry(request) @@ -18736,6 +18765,7 @@ def test_update_glossary_entry_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_glossary_entry(**mock_args) @@ -18869,6 +18899,7 @@ def test_delete_glossary_entry_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_glossary_entry(request) @@ -18914,6 +18945,7 @@ def test_delete_glossary_entry_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_glossary_entry(**mock_args) @@ -19047,6 +19079,7 @@ def test_create_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_dataset(request) @@ -19099,6 +19132,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) @@ -19230,6 +19264,7 @@ def test_get_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_dataset(request) @@ -19275,6 +19310,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) @@ -19412,6 +19448,7 @@ def test_list_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_datasets(request) @@ -19465,6 +19502,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) @@ -19659,6 +19697,7 @@ def test_delete_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_dataset(request) @@ -19702,6 +19741,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) @@ -19838,6 +19878,7 @@ def test_create_adaptive_mt_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_adaptive_mt_dataset(request) @@ -19892,6 +19933,7 @@ def test_create_adaptive_mt_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_adaptive_mt_dataset(**mock_args) @@ -20026,6 +20068,7 @@ def test_delete_adaptive_mt_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_adaptive_mt_dataset(request) @@ -20071,6 +20114,7 @@ def test_delete_adaptive_mt_dataset_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_adaptive_mt_dataset(**mock_args) @@ -20207,6 +20251,7 @@ def test_get_adaptive_mt_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_adaptive_mt_dataset(request) @@ -20254,6 +20299,7 @@ def test_get_adaptive_mt_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_adaptive_mt_dataset(**mock_args) @@ -20398,6 +20444,7 @@ def test_list_adaptive_mt_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_adaptive_mt_datasets(request) @@ -20452,6 +20499,7 @@ def test_list_adaptive_mt_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_adaptive_mt_datasets(**mock_args) @@ -20660,6 +20708,7 @@ def test_adaptive_mt_translate_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.adaptive_mt_translate(request) @@ -20715,6 +20764,7 @@ def test_adaptive_mt_translate_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.adaptive_mt_translate(**mock_args) @@ -20851,6 +20901,7 @@ def test_get_adaptive_mt_file_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_adaptive_mt_file(request) @@ -20898,6 +20949,7 @@ def test_get_adaptive_mt_file_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_adaptive_mt_file(**mock_args) @@ -21031,6 +21083,7 @@ def test_delete_adaptive_mt_file_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_adaptive_mt_file(request) @@ -21076,6 +21129,7 @@ def test_delete_adaptive_mt_file_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_adaptive_mt_file(**mock_args) @@ -21213,6 +21267,7 @@ def test_import_adaptive_mt_file_rest_required_fields( response_value._content = json_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_adaptive_mt_file(request) @@ -21260,6 +21315,7 @@ def test_import_adaptive_mt_file_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_adaptive_mt_file(**mock_args) @@ -21403,6 +21459,7 @@ def test_list_adaptive_mt_files_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_adaptive_mt_files(request) @@ -21458,6 +21515,7 @@ def test_list_adaptive_mt_files_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_adaptive_mt_files(**mock_args) @@ -21666,6 +21724,7 @@ def test_list_adaptive_mt_sentences_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_adaptive_mt_sentences(request) @@ -21721,6 +21780,7 @@ def test_list_adaptive_mt_sentences_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_adaptive_mt_sentences(**mock_args) @@ -21919,6 +21979,7 @@ def test_import_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_data(request) @@ -21977,6 +22038,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) @@ -22115,6 +22177,7 @@ def test_export_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.export_data(request) @@ -22173,6 +22236,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) @@ -22317,6 +22381,7 @@ def test_list_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.list_examples(request) @@ -22373,6 +22438,7 @@ def test_list_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.list_examples(**mock_args) @@ -22571,6 +22637,7 @@ def test_create_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_model(request) @@ -22623,6 +22690,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) @@ -22762,6 +22830,7 @@ def test_list_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_models(request) @@ -22816,6 +22885,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) @@ -23009,6 +23079,7 @@ def test_get_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_model(request) @@ -23054,6 +23125,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) @@ -23185,6 +23257,7 @@ def test_delete_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_model(request) @@ -23228,6 +23301,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) @@ -25289,6 +25363,7 @@ def test_translate_text_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.translate_text(request) @@ -25322,6 +25397,7 @@ def test_translate_text_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.translate_text(request) # Establish that the response is the type that we expect. @@ -25361,6 +25437,7 @@ def test_translate_text_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = translation_service.TranslateTextResponse.to_json( translation_service.TranslateTextResponse() ) @@ -25407,6 +25484,7 @@ def test_romanize_text_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.romanize_text(request) @@ -25440,6 +25518,7 @@ def test_romanize_text_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.romanize_text(request) # Establish that the response is the type that we expect. @@ -25479,6 +25558,7 @@ def test_romanize_text_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = translation_service.RomanizeTextResponse.to_json( translation_service.RomanizeTextResponse() ) @@ -25525,6 +25605,7 @@ def test_detect_language_rest_bad_request( response_value.status_code = 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_language(request) @@ -25558,6 +25639,7 @@ def test_detect_language_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_language(request) # Establish that the response is the type that we expect. @@ -25597,6 +25679,7 @@ def test_detect_language_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = translation_service.DetectLanguageResponse.to_json( translation_service.DetectLanguageResponse() ) @@ -25643,6 +25726,7 @@ def test_get_supported_languages_rest_bad_request( response_value.status_code = 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_supported_languages(request) @@ -25676,6 +25760,7 @@ def test_get_supported_languages_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_supported_languages(request) # Establish that the response is the type that we expect. @@ -25715,6 +25800,7 @@ def test_get_supported_languages_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = translation_service.SupportedLanguages.to_json( translation_service.SupportedLanguages() ) @@ -25761,6 +25847,7 @@ def test_translate_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.translate_document(request) @@ -25796,6 +25883,7 @@ def test_translate_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.translate_document(request) # Establish that the response is the type that we expect. @@ -25836,6 +25924,7 @@ def test_translate_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 = translation_service.TranslateDocumentResponse.to_json( translation_service.TranslateDocumentResponse() ) @@ -25882,6 +25971,7 @@ def test_batch_translate_text_rest_bad_request( response_value.status_code = 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_translate_text(request) @@ -25912,6 +26002,7 @@ def test_batch_translate_text_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_translate_text(request) # Establish that the response is the type that we expect. @@ -25953,6 +26044,7 @@ def test_batch_translate_text_rest_interceptors(null_interceptor): req.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 @@ -25997,6 +26089,7 @@ def test_batch_translate_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.batch_translate_document(request) @@ -26027,6 +26120,7 @@ def test_batch_translate_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.batch_translate_document(request) # Establish that the response is the type that we expect. @@ -26068,6 +26162,7 @@ def test_batch_translate_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 @@ -26112,6 +26207,7 @@ def test_create_glossary_rest_bad_request( response_value.status_code = 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_glossary(request) @@ -26224,6 +26320,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_glossary(request) # Establish that the response is the type that we expect. @@ -26265,6 +26362,7 @@ def test_create_glossary_rest_interceptors(null_interceptor): req.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 @@ -26311,6 +26409,7 @@ def test_update_glossary_rest_bad_request( response_value.status_code = 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_glossary(request) @@ -26425,6 +26524,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_glossary(request) # Establish that the response is the type that we expect. @@ -26466,6 +26566,7 @@ def test_update_glossary_rest_interceptors(null_interceptor): req.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 @@ -26510,6 +26611,7 @@ def test_list_glossaries_rest_bad_request( response_value.status_code = 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_glossaries(request) @@ -26545,6 +26647,7 @@ def test_list_glossaries_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_glossaries(request) # Establish that the response is the type that we expect. @@ -26585,6 +26688,7 @@ def test_list_glossaries_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = translation_service.ListGlossariesResponse.to_json( translation_service.ListGlossariesResponse() ) @@ -26631,6 +26735,7 @@ def test_get_glossary_rest_bad_request( response_value.status_code = 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_glossary(request) @@ -26668,6 +26773,7 @@ def test_get_glossary_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_glossary(request) # Establish that the response is the type that we expect. @@ -26710,6 +26816,7 @@ def test_get_glossary_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = translation_service.Glossary.to_json( translation_service.Glossary() ) @@ -26756,6 +26863,7 @@ def test_delete_glossary_rest_bad_request( response_value.status_code = 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_glossary(request) @@ -26786,6 +26894,7 @@ def test_delete_glossary_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_glossary(request) # Establish that the response is the type that we expect. @@ -26827,6 +26936,7 @@ def test_delete_glossary_rest_interceptors(null_interceptor): req.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 @@ -26873,6 +26983,7 @@ def test_get_glossary_entry_rest_bad_request( response_value.status_code = 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_glossary_entry(request) @@ -26911,6 +27022,7 @@ def test_get_glossary_entry_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_glossary_entry(request) # Establish that the response is the type that we expect. @@ -26952,6 +27064,7 @@ def test_get_glossary_entry_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = common.GlossaryEntry.to_json(common.GlossaryEntry()) req.return_value.content = return_value @@ -26996,6 +27109,7 @@ def test_list_glossary_entries_rest_bad_request( response_value.status_code = 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_glossary_entries(request) @@ -27031,6 +27145,7 @@ def test_list_glossary_entries_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_glossary_entries(request) # Establish that the response is the type that we expect. @@ -27071,6 +27186,7 @@ def test_list_glossary_entries_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = translation_service.ListGlossaryEntriesResponse.to_json( translation_service.ListGlossaryEntriesResponse() ) @@ -27117,6 +27233,7 @@ def test_create_glossary_entry_rest_bad_request( response_value.status_code = 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_glossary_entry(request) @@ -27234,6 +27351,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_glossary_entry(request) # Establish that the response is the type that we expect. @@ -27275,6 +27393,7 @@ def test_create_glossary_entry_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = common.GlossaryEntry.to_json(common.GlossaryEntry()) req.return_value.content = return_value @@ -27323,6 +27442,7 @@ def test_update_glossary_entry_rest_bad_request( response_value.status_code = 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_glossary_entry(request) @@ -27444,6 +27564,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_glossary_entry(request) # Establish that the response is the type that we expect. @@ -27485,6 +27606,7 @@ def test_update_glossary_entry_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = common.GlossaryEntry.to_json(common.GlossaryEntry()) req.return_value.content = return_value @@ -27531,6 +27653,7 @@ def test_delete_glossary_entry_rest_bad_request( response_value.status_code = 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_glossary_entry(request) @@ -27563,6 +27686,7 @@ def test_delete_glossary_entry_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_glossary_entry(request) # Establish that the response is the type that we expect. @@ -27599,6 +27723,7 @@ def test_delete_glossary_entry_rest_interceptors(null_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 = translation_service.DeleteGlossaryEntryRequest() metadata = [ @@ -27639,6 +27764,7 @@ def test_create_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_dataset(request) @@ -27748,6 +27874,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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. @@ -27789,6 +27916,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 @@ -27833,6 +27961,7 @@ def test_get_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_dataset(request) @@ -27875,6 +28004,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. @@ -27922,6 +28052,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 = automl_translation.Dataset.to_json(automl_translation.Dataset()) req.return_value.content = return_value @@ -27966,6 +28097,7 @@ def test_list_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_datasets(request) @@ -28001,6 +28133,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. @@ -28041,6 +28174,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 = automl_translation.ListDatasetsResponse.to_json( automl_translation.ListDatasetsResponse() ) @@ -28087,6 +28221,7 @@ def test_delete_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_dataset(request) @@ -28117,6 +28252,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. @@ -28158,6 +28294,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 @@ -28202,6 +28339,7 @@ def test_create_adaptive_mt_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_adaptive_mt_dataset(request) @@ -28319,6 +28457,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_adaptive_mt_dataset(request) # Establish that the response is the type that we expect. @@ -28363,6 +28502,7 @@ def test_create_adaptive_mt_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 = adaptive_mt.AdaptiveMtDataset.to_json( adaptive_mt.AdaptiveMtDataset() ) @@ -28411,6 +28551,7 @@ def test_delete_adaptive_mt_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_adaptive_mt_dataset(request) @@ -28443,6 +28584,7 @@ def test_delete_adaptive_mt_dataset_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_adaptive_mt_dataset(request) # Establish that the response is the type that we expect. @@ -28479,6 +28621,7 @@ def test_delete_adaptive_mt_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"} request = adaptive_mt.DeleteAdaptiveMtDatasetRequest() metadata = [ @@ -28521,6 +28664,7 @@ def test_get_adaptive_mt_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_adaptive_mt_dataset(request) @@ -28562,6 +28706,7 @@ def test_get_adaptive_mt_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_adaptive_mt_dataset(request) # Establish that the response is the type that we expect. @@ -28606,6 +28751,7 @@ def test_get_adaptive_mt_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 = adaptive_mt.AdaptiveMtDataset.to_json( adaptive_mt.AdaptiveMtDataset() ) @@ -28652,6 +28798,7 @@ def test_list_adaptive_mt_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_adaptive_mt_datasets(request) @@ -28687,6 +28834,7 @@ def test_list_adaptive_mt_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_adaptive_mt_datasets(request) # Establish that the response is the type that we expect. @@ -28727,6 +28875,7 @@ def test_list_adaptive_mt_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 = adaptive_mt.ListAdaptiveMtDatasetsResponse.to_json( adaptive_mt.ListAdaptiveMtDatasetsResponse() ) @@ -28773,6 +28922,7 @@ def test_adaptive_mt_translate_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.adaptive_mt_translate(request) @@ -28808,6 +28958,7 @@ def test_adaptive_mt_translate_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.adaptive_mt_translate(request) # Establish that the response is the type that we expect. @@ -28848,6 +28999,7 @@ def test_adaptive_mt_translate_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = adaptive_mt.AdaptiveMtTranslateResponse.to_json( adaptive_mt.AdaptiveMtTranslateResponse() ) @@ -28896,6 +29048,7 @@ def test_get_adaptive_mt_file_rest_bad_request( response_value.status_code = 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_adaptive_mt_file(request) @@ -28935,6 +29088,7 @@ def test_get_adaptive_mt_file_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_adaptive_mt_file(request) # Establish that the response is the type that we expect. @@ -28977,6 +29131,7 @@ def test_get_adaptive_mt_file_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = adaptive_mt.AdaptiveMtFile.to_json(adaptive_mt.AdaptiveMtFile()) req.return_value.content = return_value @@ -29023,6 +29178,7 @@ def test_delete_adaptive_mt_file_rest_bad_request( response_value.status_code = 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_adaptive_mt_file(request) @@ -29055,6 +29211,7 @@ def test_delete_adaptive_mt_file_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_adaptive_mt_file(request) # Establish that the response is the type that we expect. @@ -29091,6 +29248,7 @@ def test_delete_adaptive_mt_file_rest_interceptors(null_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 = adaptive_mt.DeleteAdaptiveMtFileRequest() metadata = [ @@ -29133,6 +29291,7 @@ def test_import_adaptive_mt_file_rest_bad_request( response_value.status_code = 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_adaptive_mt_file(request) @@ -29168,6 +29327,7 @@ def test_import_adaptive_mt_file_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_adaptive_mt_file(request) # Establish that the response is the type that we expect. @@ -29207,6 +29367,7 @@ def test_import_adaptive_mt_file_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = adaptive_mt.ImportAdaptiveMtFileResponse.to_json( adaptive_mt.ImportAdaptiveMtFileResponse() ) @@ -29255,6 +29416,7 @@ def test_list_adaptive_mt_files_rest_bad_request( response_value.status_code = 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_adaptive_mt_files(request) @@ -29292,6 +29454,7 @@ def test_list_adaptive_mt_files_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_adaptive_mt_files(request) # Establish that the response is the type that we expect. @@ -29332,6 +29495,7 @@ def test_list_adaptive_mt_files_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = adaptive_mt.ListAdaptiveMtFilesResponse.to_json( adaptive_mt.ListAdaptiveMtFilesResponse() ) @@ -29380,6 +29544,7 @@ def test_list_adaptive_mt_sentences_rest_bad_request( response_value.status_code = 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_adaptive_mt_sentences(request) @@ -29417,6 +29582,7 @@ def test_list_adaptive_mt_sentences_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_adaptive_mt_sentences(request) # Establish that the response is the type that we expect. @@ -29457,6 +29623,7 @@ def test_list_adaptive_mt_sentences_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = adaptive_mt.ListAdaptiveMtSentencesResponse.to_json( adaptive_mt.ListAdaptiveMtSentencesResponse() ) @@ -29503,6 +29670,7 @@ def test_import_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_data(request) @@ -29533,6 +29701,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. @@ -29574,6 +29743,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 @@ -29618,6 +29788,7 @@ def test_export_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.export_data(request) @@ -29648,6 +29819,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. @@ -29689,6 +29861,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 @@ -29733,6 +29906,7 @@ def test_list_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.list_examples(request) @@ -29768,6 +29942,7 @@ def test_list_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.list_examples(request) # Establish that the response is the type that we expect. @@ -29808,6 +29983,7 @@ def test_list_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 = automl_translation.ListExamplesResponse.to_json( automl_translation.ListExamplesResponse() ) @@ -29854,6 +30030,7 @@ def test_create_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_model(request) @@ -29963,6 +30140,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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. @@ -30004,6 +30182,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 @@ -30048,6 +30227,7 @@ def test_list_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_models(request) @@ -30083,6 +30263,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. @@ -30123,6 +30304,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 = automl_translation.ListModelsResponse.to_json( automl_translation.ListModelsResponse() ) @@ -30167,6 +30349,7 @@ def test_get_model_rest_bad_request(request_type=automl_translation.GetModelRequ response_value.status_code = 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) @@ -30209,6 +30392,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. @@ -30256,6 +30440,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 = automl_translation.Model.to_json(automl_translation.Model()) req.return_value.content = return_value @@ -30300,6 +30485,7 @@ def test_delete_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_model(request) @@ -30330,6 +30516,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. @@ -30371,6 +30558,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 @@ -30415,6 +30603,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) @@ -30445,6 +30634,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) @@ -30473,6 +30663,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) @@ -30503,6 +30694,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) @@ -30533,6 +30725,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) @@ -30563,6 +30756,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) @@ -30593,6 +30787,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) @@ -30623,6 +30818,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) @@ -30653,6 +30849,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) @@ -30683,6 +30880,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) @@ -30713,6 +30911,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) @@ -30743,6 +30942,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) @@ -30773,6 +30973,7 @@ def test_wait_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.wait_operation(request) @@ -30803,6 +31004,7 @@ def test_wait_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.wait_operation(request) diff --git a/packages/google-cloud-translate/tests/unit/gapic/translate_v3beta1/test_translation_service.py b/packages/google-cloud-translate/tests/unit/gapic/translate_v3beta1/test_translation_service.py index f15bd68b6b37..dd256d6153d4 100644 --- a/packages/google-cloud-translate/tests/unit/gapic/translate_v3beta1/test_translation_service.py +++ b/packages/google-cloud-translate/tests/unit/gapic/translate_v3beta1/test_translation_service.py @@ -4674,6 +4674,7 @@ def test_translate_text_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.translate_text(request) @@ -4803,6 +4804,7 @@ def test_detect_language_rest_required_fields( response_value._content = json_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_language(request) @@ -4850,6 +4852,7 @@ def test_detect_language_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_language(**mock_args) @@ -4995,6 +4998,7 @@ def test_get_supported_languages_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_supported_languages(request) @@ -5050,6 +5054,7 @@ def test_get_supported_languages_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_supported_languages(**mock_args) @@ -5194,6 +5199,7 @@ def test_translate_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.translate_document(request) @@ -5336,6 +5342,7 @@ def test_batch_translate_text_rest_required_fields( response_value._content = json_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_translate_text(request) @@ -5481,6 +5488,7 @@ def test_batch_translate_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.batch_translate_document(request) @@ -5549,6 +5557,7 @@ def test_batch_translate_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.batch_translate_document(**mock_args) @@ -5696,6 +5705,7 @@ def test_create_glossary_rest_required_fields( response_value._content = json_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_glossary(request) @@ -5748,6 +5758,7 @@ def test_create_glossary_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_glossary(**mock_args) @@ -5888,6 +5899,7 @@ def test_list_glossaries_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_glossaries(request) @@ -5943,6 +5955,7 @@ def test_list_glossaries_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_glossaries(**mock_args) @@ -6138,6 +6151,7 @@ def test_get_glossary_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_glossary(request) @@ -6185,6 +6199,7 @@ def test_get_glossary_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_glossary(**mock_args) @@ -6317,6 +6332,7 @@ def test_delete_glossary_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_glossary(request) @@ -6362,6 +6378,7 @@ def test_delete_glossary_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_glossary(**mock_args) @@ -7022,6 +7039,7 @@ def test_translate_text_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.translate_text(request) @@ -7055,6 +7073,7 @@ def test_translate_text_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.translate_text(request) # Establish that the response is the type that we expect. @@ -7094,6 +7113,7 @@ def test_translate_text_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = translation_service.TranslateTextResponse.to_json( translation_service.TranslateTextResponse() ) @@ -7140,6 +7160,7 @@ def test_detect_language_rest_bad_request( response_value.status_code = 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_language(request) @@ -7173,6 +7194,7 @@ def test_detect_language_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_language(request) # Establish that the response is the type that we expect. @@ -7212,6 +7234,7 @@ def test_detect_language_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = translation_service.DetectLanguageResponse.to_json( translation_service.DetectLanguageResponse() ) @@ -7258,6 +7281,7 @@ def test_get_supported_languages_rest_bad_request( response_value.status_code = 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_supported_languages(request) @@ -7291,6 +7315,7 @@ def test_get_supported_languages_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_supported_languages(request) # Establish that the response is the type that we expect. @@ -7330,6 +7355,7 @@ def test_get_supported_languages_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = translation_service.SupportedLanguages.to_json( translation_service.SupportedLanguages() ) @@ -7376,6 +7402,7 @@ def test_translate_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.translate_document(request) @@ -7411,6 +7438,7 @@ def test_translate_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.translate_document(request) # Establish that the response is the type that we expect. @@ -7451,6 +7479,7 @@ def test_translate_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 = translation_service.TranslateDocumentResponse.to_json( translation_service.TranslateDocumentResponse() ) @@ -7497,6 +7526,7 @@ def test_batch_translate_text_rest_bad_request( response_value.status_code = 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_translate_text(request) @@ -7527,6 +7557,7 @@ def test_batch_translate_text_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_translate_text(request) # Establish that the response is the type that we expect. @@ -7568,6 +7599,7 @@ def test_batch_translate_text_rest_interceptors(null_interceptor): req.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 @@ -7612,6 +7644,7 @@ def test_batch_translate_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.batch_translate_document(request) @@ -7642,6 +7675,7 @@ def test_batch_translate_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.batch_translate_document(request) # Establish that the response is the type that we expect. @@ -7683,6 +7717,7 @@ def test_batch_translate_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 @@ -7727,6 +7762,7 @@ def test_create_glossary_rest_bad_request( response_value.status_code = 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_glossary(request) @@ -7838,6 +7874,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_glossary(request) # Establish that the response is the type that we expect. @@ -7879,6 +7916,7 @@ def test_create_glossary_rest_interceptors(null_interceptor): req.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 @@ -7923,6 +7961,7 @@ def test_list_glossaries_rest_bad_request( response_value.status_code = 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_glossaries(request) @@ -7958,6 +7997,7 @@ def test_list_glossaries_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_glossaries(request) # Establish that the response is the type that we expect. @@ -7998,6 +8038,7 @@ def test_list_glossaries_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = translation_service.ListGlossariesResponse.to_json( translation_service.ListGlossariesResponse() ) @@ -8044,6 +8085,7 @@ def test_get_glossary_rest_bad_request( response_value.status_code = 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_glossary(request) @@ -8080,6 +8122,7 @@ def test_get_glossary_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_glossary(request) # Establish that the response is the type that we expect. @@ -8121,6 +8164,7 @@ def test_get_glossary_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = translation_service.Glossary.to_json( translation_service.Glossary() ) @@ -8167,6 +8211,7 @@ def test_delete_glossary_rest_bad_request( response_value.status_code = 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_glossary(request) @@ -8197,6 +8242,7 @@ def test_delete_glossary_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_glossary(request) # Establish that the response is the type that we expect. @@ -8238,6 +8284,7 @@ def test_delete_glossary_rest_interceptors(null_interceptor): req.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-video-live-stream/google/cloud/video/live_stream/gapic_version.py b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream/gapic_version.py index 402b34e179e9..558c8aab67c5 100644 --- a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream/gapic_version.py +++ b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.9.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/gapic_version.py b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/gapic_version.py index 402b34e179e9..558c8aab67c5 100644 --- a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/gapic_version.py +++ b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.9.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/async_client.py b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/async_client.py index 73478d4d6652..e8f2db98506c 100644 --- a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/async_client.py +++ b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_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, @@ -58,6 +59,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, LivestreamServiceTransport from .transports.grpc_asyncio import LivestreamServiceGrpcAsyncIOTransport +try: + from google.api_core import client_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 LivestreamServiceAsyncClient: """Using Live Stream API, you can generate live streams in the @@ -289,6 +299,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.video.livestream_v1.LivestreamServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "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.video.livestream.v1.LivestreamService", + "credentialsType": None, + }, + ) + async def create_channel( self, request: Optional[Union[service.CreateChannelRequest, dict]] = None, @@ -298,7 +330,7 @@ async def create_channel( channel_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 channel with the provided unique ID in the specified region. @@ -363,8 +395,10 @@ async def sample_create_channel(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -443,7 +477,7 @@ async def list_channels( 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.ListChannelsAsyncPager: r"""Returns a list of all channels in the specified region. @@ -489,8 +523,10 @@ async def sample_list_channels(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListChannelsAsyncPager: @@ -565,7 +601,7 @@ async def get_channel( name: Optional[str] = None, retry: OptionalRetry = 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.Channel: r"""Returns the specified channel. @@ -610,8 +646,10 @@ async def sample_get_channel(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.live_stream_v1.types.Channel: @@ -678,7 +716,7 @@ async def delete_channel( name: Optional[str] = None, retry: OptionalRetry = gapic_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 channel. @@ -727,8 +765,10 @@ async def sample_delete_channel(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -808,7 +848,7 @@ async def update_channel( 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 channel. @@ -883,8 +923,10 @@ async def sample_update_channel(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -963,7 +1005,7 @@ async def start_channel( name: Optional[str] = None, retry: OptionalRetry = gapic_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"""Starts the specified channel. Part of the video pipeline will be created only when the StartChannel @@ -1014,8 +1056,10 @@ async def sample_start_channel(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1088,7 +1132,7 @@ async def stop_channel( name: Optional[str] = None, retry: OptionalRetry = gapic_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"""Stops the specified channel. Part of the video pipeline will be released when the StopChannel request @@ -1139,8 +1183,10 @@ async def sample_stop_channel(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1215,7 +1261,7 @@ async def create_input( input_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 an input with the provided unique ID in the specified region. @@ -1280,8 +1326,10 @@ async def sample_create_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.api_core.operation_async.AsyncOperation: @@ -1356,7 +1404,7 @@ async def list_inputs( 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.ListInputsAsyncPager: r"""Returns a list of all inputs in the specified region. @@ -1401,8 +1449,10 @@ async def sample_list_inputs(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListInputsAsyncPager: @@ -1477,7 +1527,7 @@ async def get_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]]] = (), ) -> resources.Input: r"""Returns the specified input. @@ -1522,8 +1572,10 @@ async def sample_get_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.cloud.video.live_stream_v1.types.Input: @@ -1585,7 +1637,7 @@ async def delete_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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the specified input. @@ -1634,8 +1686,10 @@ async def sample_delete_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.api_core.operation_async.AsyncOperation: @@ -1715,7 +1769,7 @@ async def update_input( 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 input. @@ -1782,8 +1836,10 @@ async def sample_update_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.api_core.operation_async.AsyncOperation: @@ -1860,7 +1916,7 @@ async def create_event( event_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.Event: r"""Creates an event with the provided unique ID in the specified channel. @@ -1922,8 +1978,10 @@ async def sample_create_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.cloud.video.live_stream_v1.types.Event: @@ -1990,7 +2048,7 @@ async def list_events( 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.ListEventsAsyncPager: r"""Returns a list of all events in the specified channel. @@ -2037,8 +2095,10 @@ async def sample_list_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.cloud.video.live_stream_v1.services.livestream_service.pagers.ListEventsAsyncPager: @@ -2113,7 +2173,7 @@ async def get_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]]] = (), ) -> resources.Event: r"""Returns the specified event. @@ -2158,8 +2218,10 @@ async def sample_get_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.cloud.video.live_stream_v1.types.Event: @@ -2222,7 +2284,7 @@ async def delete_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]]] = (), ) -> None: r"""Deletes the specified event. @@ -2264,8 +2326,10 @@ async def sample_delete_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2317,7 +2381,7 @@ async def list_clips( 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.ListClipsAsyncPager: r"""Returns a list of all clips in the specified channel. @@ -2362,8 +2426,10 @@ async def sample_list_clips(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListClipsAsyncPager: @@ -2438,7 +2504,7 @@ async def get_clip( name: Optional[str] = None, retry: OptionalRetry = 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.Clip: r"""Returns the specified clip. @@ -2482,8 +2548,10 @@ async def sample_get_clip(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.live_stream_v1.types.Clip: @@ -2547,7 +2615,7 @@ async def create_clip( clip_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 clip with the provided clip ID in the specified channel. @@ -2619,8 +2687,10 @@ async def sample_create_clip(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2696,7 +2766,7 @@ async def delete_clip( name: Optional[str] = None, retry: OptionalRetry = gapic_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 clip job resource. This method only deletes the clip job and does not delete the VOD @@ -2746,8 +2816,10 @@ async def sample_delete_clip(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2828,7 +2900,7 @@ async def create_asset( asset_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 Asset with the provided unique ID in the specified region. @@ -2893,8 +2965,10 @@ async def sample_create_asset(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2970,7 +3044,7 @@ async def delete_asset( name: Optional[str] = None, retry: OptionalRetry = gapic_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 asset if it is not used. @@ -3019,8 +3093,10 @@ async def sample_delete_asset(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3099,7 +3175,7 @@ async def get_asset( name: Optional[str] = None, retry: OptionalRetry = 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.Asset: r"""Returns the specified asset. @@ -3143,8 +3219,10 @@ async def sample_get_asset(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.live_stream_v1.types.Asset: @@ -3205,7 +3283,7 @@ async def list_assets( 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.ListAssetsAsyncPager: r"""Returns a list of all assets in the specified region. @@ -3250,8 +3328,10 @@ async def sample_list_assets(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListAssetsAsyncPager: @@ -3326,7 +3406,7 @@ async def get_pool( name: Optional[str] = None, retry: OptionalRetry = 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.Pool: r"""Returns the specified pool. @@ -3370,8 +3450,10 @@ async def sample_get_pool(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.live_stream_v1.types.Pool: @@ -3437,7 +3519,7 @@ async def update_pool( 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 pool. @@ -3498,8 +3580,10 @@ async def sample_update_pool(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3577,7 +3661,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. @@ -3588,8 +3672,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. @@ -3630,7 +3716,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. @@ -3641,8 +3727,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. @@ -3683,7 +3771,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. @@ -3699,8 +3787,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 """ @@ -3737,7 +3827,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. @@ -3752,8 +3842,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 """ @@ -3790,7 +3882,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. @@ -3801,8 +3893,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. @@ -3843,7 +3937,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. @@ -3854,8 +3948,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-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/client.py b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/client.py index 89c9e9a3cfb9..0f7387cd1f24 100644 --- a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/client.py +++ b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_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 @@ -752,6 +762,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( @@ -818,6 +832,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.video.livestream_v1.LivestreamServiceClient`.", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "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.video.livestream.v1.LivestreamService", + "credentialsType": None, + }, + ) + def create_channel( self, request: Optional[Union[service.CreateChannelRequest, dict]] = None, @@ -827,7 +864,7 @@ def create_channel( channel_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 channel with the provided unique ID in the specified region. @@ -892,8 +929,10 @@ def sample_create_channel(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -969,7 +1008,7 @@ def list_channels( 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.ListChannelsPager: r"""Returns a list of all channels in the specified region. @@ -1015,8 +1054,10 @@ def sample_list_channels(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListChannelsPager: @@ -1088,7 +1129,7 @@ def get_channel( name: Optional[str] = None, retry: OptionalRetry = 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.Channel: r"""Returns the specified channel. @@ -1133,8 +1174,10 @@ def sample_get_channel(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.live_stream_v1.types.Channel: @@ -1198,7 +1241,7 @@ def delete_channel( name: Optional[str] = None, retry: OptionalRetry = gapic_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 channel. @@ -1247,8 +1290,10 @@ def sample_delete_channel(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1325,7 +1370,7 @@ def update_channel( 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 channel. @@ -1400,8 +1445,10 @@ def sample_update_channel(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1477,7 +1524,7 @@ def start_channel( name: Optional[str] = None, retry: OptionalRetry = gapic_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"""Starts the specified channel. Part of the video pipeline will be created only when the StartChannel @@ -1528,8 +1575,10 @@ def sample_start_channel(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1599,7 +1648,7 @@ def stop_channel( name: Optional[str] = None, retry: OptionalRetry = gapic_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"""Stops the specified channel. Part of the video pipeline will be released when the StopChannel request @@ -1650,8 +1699,10 @@ def sample_stop_channel(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1723,7 +1774,7 @@ def create_input( input_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 an input with the provided unique ID in the specified region. @@ -1788,8 +1839,10 @@ def sample_create_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.api_core.operation.Operation: @@ -1861,7 +1914,7 @@ def list_inputs( 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.ListInputsPager: r"""Returns a list of all inputs in the specified region. @@ -1906,8 +1959,10 @@ def sample_list_inputs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListInputsPager: @@ -1979,7 +2034,7 @@ def get_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]]] = (), ) -> resources.Input: r"""Returns the specified input. @@ -2024,8 +2079,10 @@ def sample_get_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.cloud.video.live_stream_v1.types.Input: @@ -2084,7 +2141,7 @@ def delete_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]]] = (), ) -> operation.Operation: r"""Deletes the specified input. @@ -2133,8 +2190,10 @@ def sample_delete_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.api_core.operation.Operation: @@ -2211,7 +2270,7 @@ def update_input( 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 input. @@ -2278,8 +2337,10 @@ def sample_update_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.api_core.operation.Operation: @@ -2353,7 +2414,7 @@ def create_event( event_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.Event: r"""Creates an event with the provided unique ID in the specified channel. @@ -2415,8 +2476,10 @@ def sample_create_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.cloud.video.live_stream_v1.types.Event: @@ -2480,7 +2543,7 @@ def list_events( 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.ListEventsPager: r"""Returns a list of all events in the specified channel. @@ -2527,8 +2590,10 @@ def sample_list_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.cloud.video.live_stream_v1.services.livestream_service.pagers.ListEventsPager: @@ -2600,7 +2665,7 @@ def get_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]]] = (), ) -> resources.Event: r"""Returns the specified event. @@ -2645,8 +2710,10 @@ def sample_get_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.cloud.video.live_stream_v1.types.Event: @@ -2706,7 +2773,7 @@ def delete_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]]] = (), ) -> None: r"""Deletes the specified event. @@ -2748,8 +2815,10 @@ def sample_delete_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2798,7 +2867,7 @@ def list_clips( 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.ListClipsPager: r"""Returns a list of all clips in the specified channel. @@ -2843,8 +2912,10 @@ def sample_list_clips(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListClipsPager: @@ -2916,7 +2987,7 @@ def get_clip( name: Optional[str] = None, retry: OptionalRetry = 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.Clip: r"""Returns the specified clip. @@ -2960,8 +3031,10 @@ def sample_get_clip(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.live_stream_v1.types.Clip: @@ -3024,7 +3097,7 @@ def create_clip( clip_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 clip with the provided clip ID in the specified channel. @@ -3096,8 +3169,10 @@ def sample_create_clip(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3170,7 +3245,7 @@ def delete_clip( name: Optional[str] = None, retry: OptionalRetry = gapic_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 clip job resource. This method only deletes the clip job and does not delete the VOD @@ -3220,8 +3295,10 @@ def sample_delete_clip(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3299,7 +3376,7 @@ def create_asset( asset_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 Asset with the provided unique ID in the specified region. @@ -3364,8 +3441,10 @@ def sample_create_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3438,7 +3517,7 @@ def delete_asset( name: Optional[str] = None, retry: OptionalRetry = gapic_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 asset if it is not used. @@ -3487,8 +3566,10 @@ def sample_delete_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3564,7 +3645,7 @@ def get_asset( name: Optional[str] = None, retry: OptionalRetry = 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.Asset: r"""Returns the specified asset. @@ -3608,8 +3689,10 @@ def sample_get_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.live_stream_v1.types.Asset: @@ -3667,7 +3750,7 @@ def list_assets( 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.ListAssetsPager: r"""Returns a list of all assets in the specified region. @@ -3712,8 +3795,10 @@ def sample_list_assets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListAssetsPager: @@ -3785,7 +3870,7 @@ def get_pool( name: Optional[str] = None, retry: OptionalRetry = 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.Pool: r"""Returns the specified pool. @@ -3829,8 +3914,10 @@ def sample_get_pool(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.live_stream_v1.types.Pool: @@ -3895,7 +3982,7 @@ def update_pool( 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 pool. @@ -3956,8 +4043,10 @@ def sample_update_pool(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -4045,7 +4134,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. @@ -4056,8 +4145,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. @@ -4098,7 +4189,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. @@ -4109,8 +4200,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. @@ -4151,7 +4244,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. @@ -4167,8 +4260,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 """ @@ -4205,7 +4300,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. @@ -4220,8 +4315,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 """ @@ -4258,7 +4355,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. @@ -4269,8 +4366,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. @@ -4311,7 +4410,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. @@ -4322,8 +4421,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-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/pagers.py b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/pagers.py index b07985c95e59..477d2d52cdb6 100644 --- a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/pagers.py +++ b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_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 = service.ListChannelsRequest(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.ListChannelsRequest(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.ListInputsRequest(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.ListInputsRequest(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.ListEventsRequest(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.ListEventsRequest(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 = service.ListClipsRequest(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 = service.ListClipsRequest(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 = service.ListAssetsRequest(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 = service.ListAssetsRequest(request) diff --git a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/transports/grpc.py b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/transports/grpc.py index 126318a1f00d..7269a445e673 100644 --- a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/transports/grpc.py +++ b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_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 @@ -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.video.live_stream_v1.types import resources, service from .base import DEFAULT_CLIENT_INFO, LivestreamServiceTransport +try: + from google.api_core import client_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.video.livestream.v1.LivestreamService", + "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.video.livestream.v1.LivestreamService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class LivestreamServiceGrpcTransport(LivestreamServiceTransport): """gRPC backend transport for LivestreamService. @@ -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 @@ -277,7 +365,7 @@ def create_channel_( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_channel_" not in self._stubs: - self._stubs["create_channel_"] = self.grpc_channel.unary_unary( + self._stubs["create_channel_"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/CreateChannel", request_serializer=service.CreateChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -304,7 +392,7 @@ def list_channels( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_channels" not in self._stubs: - self._stubs["list_channels"] = self.grpc_channel.unary_unary( + self._stubs["list_channels"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/ListChannels", request_serializer=service.ListChannelsRequest.serialize, response_deserializer=service.ListChannelsResponse.deserialize, @@ -328,7 +416,7 @@ def get_channel(self) -> Callable[[service.GetChannelRequest], resources.Channel # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_channel" not in self._stubs: - self._stubs["get_channel"] = self.grpc_channel.unary_unary( + self._stubs["get_channel"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/GetChannel", request_serializer=service.GetChannelRequest.serialize, response_deserializer=resources.Channel.deserialize, @@ -354,7 +442,7 @@ def delete_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_channel" not in self._stubs: - self._stubs["delete_channel"] = self.grpc_channel.unary_unary( + self._stubs["delete_channel"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/DeleteChannel", request_serializer=service.DeleteChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -380,7 +468,7 @@ def update_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_channel" not in self._stubs: - self._stubs["update_channel"] = self.grpc_channel.unary_unary( + self._stubs["update_channel"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/UpdateChannel", request_serializer=service.UpdateChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -408,7 +496,7 @@ def start_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_channel" not in self._stubs: - self._stubs["start_channel"] = self.grpc_channel.unary_unary( + self._stubs["start_channel"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/StartChannel", request_serializer=service.StartChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -436,7 +524,7 @@ def stop_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_channel" not in self._stubs: - self._stubs["stop_channel"] = self.grpc_channel.unary_unary( + self._stubs["stop_channel"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/StopChannel", request_serializer=service.StopChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -463,7 +551,7 @@ def create_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_input" not in self._stubs: - self._stubs["create_input"] = self.grpc_channel.unary_unary( + self._stubs["create_input"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/CreateInput", request_serializer=service.CreateInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -489,7 +577,7 @@ def list_inputs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_inputs" not in self._stubs: - self._stubs["list_inputs"] = self.grpc_channel.unary_unary( + self._stubs["list_inputs"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/ListInputs", request_serializer=service.ListInputsRequest.serialize, response_deserializer=service.ListInputsResponse.deserialize, @@ -513,7 +601,7 @@ def get_input(self) -> Callable[[service.GetInputRequest], resources.Input]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_input" not in self._stubs: - self._stubs["get_input"] = self.grpc_channel.unary_unary( + self._stubs["get_input"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/GetInput", request_serializer=service.GetInputRequest.serialize, response_deserializer=resources.Input.deserialize, @@ -539,7 +627,7 @@ def delete_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_input" not in self._stubs: - self._stubs["delete_input"] = self.grpc_channel.unary_unary( + self._stubs["delete_input"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/DeleteInput", request_serializer=service.DeleteInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -565,7 +653,7 @@ def update_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_input" not in self._stubs: - self._stubs["update_input"] = self.grpc_channel.unary_unary( + self._stubs["update_input"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/UpdateInput", request_serializer=service.UpdateInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -590,7 +678,7 @@ def create_event(self) -> Callable[[service.CreateEventRequest], resources.Event # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_event" not in self._stubs: - self._stubs["create_event"] = self.grpc_channel.unary_unary( + self._stubs["create_event"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/CreateEvent", request_serializer=service.CreateEventRequest.serialize, response_deserializer=resources.Event.deserialize, @@ -617,7 +705,7 @@ def list_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_events" not in self._stubs: - self._stubs["list_events"] = self.grpc_channel.unary_unary( + self._stubs["list_events"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/ListEvents", request_serializer=service.ListEventsRequest.serialize, response_deserializer=service.ListEventsResponse.deserialize, @@ -641,7 +729,7 @@ def get_event(self) -> Callable[[service.GetEventRequest], resources.Event]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_event" not in self._stubs: - self._stubs["get_event"] = self.grpc_channel.unary_unary( + self._stubs["get_event"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/GetEvent", request_serializer=service.GetEventRequest.serialize, response_deserializer=resources.Event.deserialize, @@ -665,7 +753,7 @@ def delete_event(self) -> Callable[[service.DeleteEventRequest], empty_pb2.Empty # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_event" not in self._stubs: - self._stubs["delete_event"] = self.grpc_channel.unary_unary( + self._stubs["delete_event"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/DeleteEvent", request_serializer=service.DeleteEventRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -691,7 +779,7 @@ def list_clips( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_clips" not in self._stubs: - self._stubs["list_clips"] = self.grpc_channel.unary_unary( + self._stubs["list_clips"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/ListClips", request_serializer=service.ListClipsRequest.serialize, response_deserializer=service.ListClipsResponse.deserialize, @@ -715,7 +803,7 @@ def get_clip(self) -> Callable[[service.GetClipRequest], resources.Clip]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_clip" not in self._stubs: - self._stubs["get_clip"] = self.grpc_channel.unary_unary( + self._stubs["get_clip"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/GetClip", request_serializer=service.GetClipRequest.serialize, response_deserializer=resources.Clip.deserialize, @@ -742,7 +830,7 @@ def create_clip( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_clip" not in self._stubs: - self._stubs["create_clip"] = self.grpc_channel.unary_unary( + self._stubs["create_clip"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/CreateClip", request_serializer=service.CreateClipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -770,7 +858,7 @@ def delete_clip( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_clip" not in self._stubs: - self._stubs["delete_clip"] = self.grpc_channel.unary_unary( + self._stubs["delete_clip"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/DeleteClip", request_serializer=service.DeleteClipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -797,7 +885,7 @@ def create_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_asset" not in self._stubs: - self._stubs["create_asset"] = self.grpc_channel.unary_unary( + self._stubs["create_asset"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/CreateAsset", request_serializer=service.CreateAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -823,7 +911,7 @@ def delete_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_asset" not in self._stubs: - self._stubs["delete_asset"] = self.grpc_channel.unary_unary( + self._stubs["delete_asset"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/DeleteAsset", request_serializer=service.DeleteAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -847,7 +935,7 @@ def get_asset(self) -> Callable[[service.GetAssetRequest], resources.Asset]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_asset" not in self._stubs: - self._stubs["get_asset"] = self.grpc_channel.unary_unary( + self._stubs["get_asset"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/GetAsset", request_serializer=service.GetAssetRequest.serialize, response_deserializer=resources.Asset.deserialize, @@ -873,7 +961,7 @@ def list_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_assets" not in self._stubs: - self._stubs["list_assets"] = self.grpc_channel.unary_unary( + self._stubs["list_assets"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/ListAssets", request_serializer=service.ListAssetsRequest.serialize, response_deserializer=service.ListAssetsResponse.deserialize, @@ -897,7 +985,7 @@ def get_pool(self) -> Callable[[service.GetPoolRequest], resources.Pool]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_pool" not in self._stubs: - self._stubs["get_pool"] = self.grpc_channel.unary_unary( + self._stubs["get_pool"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/GetPool", request_serializer=service.GetPoolRequest.serialize, response_deserializer=resources.Pool.deserialize, @@ -923,7 +1011,7 @@ def update_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_pool" not in self._stubs: - self._stubs["update_pool"] = self.grpc_channel.unary_unary( + self._stubs["update_pool"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/UpdatePool", request_serializer=service.UpdatePoolRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -931,7 +1019,7 @@ def update_pool( return self._stubs["update_pool"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -943,7 +1031,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, @@ -960,7 +1048,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, @@ -977,7 +1065,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, @@ -996,7 +1084,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, @@ -1015,7 +1103,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, @@ -1032,7 +1120,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-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/transports/grpc_asyncio.py b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/transports/grpc_asyncio.py index 6e813b87fd7b..33417b7c14df 100644 --- a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_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 @@ -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.video.live_stream_v1.types import resources, service from .base import DEFAULT_CLIENT_INFO, LivestreamServiceTransport from .grpc import LivestreamServiceGrpcTransport +try: + from google.api_core import client_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.video.livestream.v1.LivestreamService", + "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.video.livestream.v1.LivestreamService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class LivestreamServiceGrpcAsyncIOTransport(LivestreamServiceTransport): """gRPC AsyncIO backend transport for LivestreamService. @@ -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 create_channel_( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_channel_" not in self._stubs: - self._stubs["create_channel_"] = self.grpc_channel.unary_unary( + self._stubs["create_channel_"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/CreateChannel", request_serializer=service.CreateChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -316,7 +401,7 @@ def list_channels( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_channels" not in self._stubs: - self._stubs["list_channels"] = self.grpc_channel.unary_unary( + self._stubs["list_channels"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/ListChannels", request_serializer=service.ListChannelsRequest.serialize, response_deserializer=service.ListChannelsResponse.deserialize, @@ -342,7 +427,7 @@ def get_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_channel" not in self._stubs: - self._stubs["get_channel"] = self.grpc_channel.unary_unary( + self._stubs["get_channel"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/GetChannel", request_serializer=service.GetChannelRequest.serialize, response_deserializer=resources.Channel.deserialize, @@ -368,7 +453,7 @@ def delete_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_channel" not in self._stubs: - self._stubs["delete_channel"] = self.grpc_channel.unary_unary( + self._stubs["delete_channel"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/DeleteChannel", request_serializer=service.DeleteChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -394,7 +479,7 @@ def update_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_channel" not in self._stubs: - self._stubs["update_channel"] = self.grpc_channel.unary_unary( + self._stubs["update_channel"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/UpdateChannel", request_serializer=service.UpdateChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -422,7 +507,7 @@ def start_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_channel" not in self._stubs: - self._stubs["start_channel"] = self.grpc_channel.unary_unary( + self._stubs["start_channel"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/StartChannel", request_serializer=service.StartChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -450,7 +535,7 @@ def stop_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_channel" not in self._stubs: - self._stubs["stop_channel"] = self.grpc_channel.unary_unary( + self._stubs["stop_channel"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/StopChannel", request_serializer=service.StopChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -477,7 +562,7 @@ def create_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_input" not in self._stubs: - self._stubs["create_input"] = self.grpc_channel.unary_unary( + self._stubs["create_input"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/CreateInput", request_serializer=service.CreateInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -503,7 +588,7 @@ def list_inputs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_inputs" not in self._stubs: - self._stubs["list_inputs"] = self.grpc_channel.unary_unary( + self._stubs["list_inputs"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/ListInputs", request_serializer=service.ListInputsRequest.serialize, response_deserializer=service.ListInputsResponse.deserialize, @@ -529,7 +614,7 @@ def get_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_input" not in self._stubs: - self._stubs["get_input"] = self.grpc_channel.unary_unary( + self._stubs["get_input"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/GetInput", request_serializer=service.GetInputRequest.serialize, response_deserializer=resources.Input.deserialize, @@ -555,7 +640,7 @@ def delete_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_input" not in self._stubs: - self._stubs["delete_input"] = self.grpc_channel.unary_unary( + self._stubs["delete_input"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/DeleteInput", request_serializer=service.DeleteInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -581,7 +666,7 @@ def update_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_input" not in self._stubs: - self._stubs["update_input"] = self.grpc_channel.unary_unary( + self._stubs["update_input"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/UpdateInput", request_serializer=service.UpdateInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -608,7 +693,7 @@ def create_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_event" not in self._stubs: - self._stubs["create_event"] = self.grpc_channel.unary_unary( + self._stubs["create_event"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/CreateEvent", request_serializer=service.CreateEventRequest.serialize, response_deserializer=resources.Event.deserialize, @@ -635,7 +720,7 @@ def list_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_events" not in self._stubs: - self._stubs["list_events"] = self.grpc_channel.unary_unary( + self._stubs["list_events"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/ListEvents", request_serializer=service.ListEventsRequest.serialize, response_deserializer=service.ListEventsResponse.deserialize, @@ -661,7 +746,7 @@ def get_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_event" not in self._stubs: - self._stubs["get_event"] = self.grpc_channel.unary_unary( + self._stubs["get_event"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/GetEvent", request_serializer=service.GetEventRequest.serialize, response_deserializer=resources.Event.deserialize, @@ -687,7 +772,7 @@ def delete_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_event" not in self._stubs: - self._stubs["delete_event"] = self.grpc_channel.unary_unary( + self._stubs["delete_event"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/DeleteEvent", request_serializer=service.DeleteEventRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -713,7 +798,7 @@ def list_clips( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_clips" not in self._stubs: - self._stubs["list_clips"] = self.grpc_channel.unary_unary( + self._stubs["list_clips"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/ListClips", request_serializer=service.ListClipsRequest.serialize, response_deserializer=service.ListClipsResponse.deserialize, @@ -737,7 +822,7 @@ def get_clip(self) -> Callable[[service.GetClipRequest], Awaitable[resources.Cli # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_clip" not in self._stubs: - self._stubs["get_clip"] = self.grpc_channel.unary_unary( + self._stubs["get_clip"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/GetClip", request_serializer=service.GetClipRequest.serialize, response_deserializer=resources.Clip.deserialize, @@ -764,7 +849,7 @@ def create_clip( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_clip" not in self._stubs: - self._stubs["create_clip"] = self.grpc_channel.unary_unary( + self._stubs["create_clip"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/CreateClip", request_serializer=service.CreateClipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -792,7 +877,7 @@ def delete_clip( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_clip" not in self._stubs: - self._stubs["delete_clip"] = self.grpc_channel.unary_unary( + self._stubs["delete_clip"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/DeleteClip", request_serializer=service.DeleteClipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -819,7 +904,7 @@ def create_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_asset" not in self._stubs: - self._stubs["create_asset"] = self.grpc_channel.unary_unary( + self._stubs["create_asset"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/CreateAsset", request_serializer=service.CreateAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -845,7 +930,7 @@ def delete_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_asset" not in self._stubs: - self._stubs["delete_asset"] = self.grpc_channel.unary_unary( + self._stubs["delete_asset"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/DeleteAsset", request_serializer=service.DeleteAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -871,7 +956,7 @@ def get_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_asset" not in self._stubs: - self._stubs["get_asset"] = self.grpc_channel.unary_unary( + self._stubs["get_asset"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/GetAsset", request_serializer=service.GetAssetRequest.serialize, response_deserializer=resources.Asset.deserialize, @@ -897,7 +982,7 @@ def list_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_assets" not in self._stubs: - self._stubs["list_assets"] = self.grpc_channel.unary_unary( + self._stubs["list_assets"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/ListAssets", request_serializer=service.ListAssetsRequest.serialize, response_deserializer=service.ListAssetsResponse.deserialize, @@ -921,7 +1006,7 @@ def get_pool(self) -> Callable[[service.GetPoolRequest], Awaitable[resources.Poo # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_pool" not in self._stubs: - self._stubs["get_pool"] = self.grpc_channel.unary_unary( + self._stubs["get_pool"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/GetPool", request_serializer=service.GetPoolRequest.serialize, response_deserializer=resources.Pool.deserialize, @@ -947,7 +1032,7 @@ def update_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_pool" not in self._stubs: - self._stubs["update_pool"] = self.grpc_channel.unary_unary( + self._stubs["update_pool"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/UpdatePool", request_serializer=service.UpdatePoolRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1179,7 +1264,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: @@ -1195,7 +1280,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, @@ -1212,7 +1297,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, @@ -1229,7 +1314,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, @@ -1248,7 +1333,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, @@ -1267,7 +1352,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, @@ -1284,7 +1369,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-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/transports/rest.py b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/transports/rest.py index a9339fc9ae77..c01a31620435 100644 --- a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/transports/rest.py +++ b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_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, @@ -274,8 +282,10 @@ def post_update_pool(self, response): """ def pre_create_asset( - self, request: service.CreateAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_asset Override in a subclass to manipulate the request or metadata @@ -295,8 +305,10 @@ def post_create_asset( return response def pre_create_channel( - self, request: service.CreateChannelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateChannelRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateChannelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateChannelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_channel Override in a subclass to manipulate the request or metadata @@ -316,8 +328,10 @@ def post_create_channel( return response def pre_create_clip( - self, request: service.CreateClipRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateClipRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateClipRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateClipRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_clip Override in a subclass to manipulate the request or metadata @@ -337,8 +351,10 @@ def post_create_clip( return response def pre_create_event( - self, request: service.CreateEventRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateEventRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateEventRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateEventRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_event Override in a subclass to manipulate the request or metadata @@ -356,8 +372,10 @@ def post_create_event(self, response: resources.Event) -> resources.Event: return response def pre_create_input( - self, request: service.CreateInputRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateInputRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateInputRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateInputRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_input Override in a subclass to manipulate the request or metadata @@ -377,8 +395,10 @@ def post_create_input( return response def pre_delete_asset( - self, request: service.DeleteAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_asset Override in a subclass to manipulate the request or metadata @@ -398,8 +418,10 @@ def post_delete_asset( return response def pre_delete_channel( - self, request: service.DeleteChannelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteChannelRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteChannelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteChannelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_channel Override in a subclass to manipulate the request or metadata @@ -419,8 +441,10 @@ def post_delete_channel( return response def pre_delete_clip( - self, request: service.DeleteClipRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteClipRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteClipRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteClipRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_clip Override in a subclass to manipulate the request or metadata @@ -440,8 +464,10 @@ def post_delete_clip( return response def pre_delete_event( - self, request: service.DeleteEventRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteEventRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteEventRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteEventRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_event Override in a subclass to manipulate the request or metadata @@ -450,8 +476,10 @@ def pre_delete_event( return request, metadata def pre_delete_input( - self, request: service.DeleteInputRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteInputRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteInputRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteInputRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_input Override in a subclass to manipulate the request or metadata @@ -471,8 +499,10 @@ def post_delete_input( return response def pre_get_asset( - self, request: service.GetAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_asset Override in a subclass to manipulate the request or metadata @@ -490,8 +520,10 @@ def post_get_asset(self, response: resources.Asset) -> resources.Asset: return response def pre_get_channel( - self, request: service.GetChannelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetChannelRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetChannelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetChannelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_channel Override in a subclass to manipulate the request or metadata @@ -509,8 +541,10 @@ def post_get_channel(self, response: resources.Channel) -> resources.Channel: return response def pre_get_clip( - self, request: service.GetClipRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetClipRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetClipRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetClipRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_clip Override in a subclass to manipulate the request or metadata @@ -528,8 +562,10 @@ def post_get_clip(self, response: resources.Clip) -> resources.Clip: return response def pre_get_event( - self, request: service.GetEventRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetEventRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetEventRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetEventRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_event Override in a subclass to manipulate the request or metadata @@ -547,8 +583,10 @@ def post_get_event(self, response: resources.Event) -> resources.Event: return response def pre_get_input( - self, request: service.GetInputRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetInputRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetInputRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetInputRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_input Override in a subclass to manipulate the request or metadata @@ -566,8 +604,10 @@ def post_get_input(self, response: resources.Input) -> resources.Input: return response def pre_get_pool( - self, request: service.GetPoolRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetPoolRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetPoolRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetPoolRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_pool Override in a subclass to manipulate the request or metadata @@ -585,8 +625,10 @@ def post_get_pool(self, response: resources.Pool) -> resources.Pool: return response def pre_list_assets( - self, request: service.ListAssetsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListAssetsRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListAssetsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListAssetsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_assets Override in a subclass to manipulate the request or metadata @@ -606,8 +648,10 @@ def post_list_assets( return response def pre_list_channels( - self, request: service.ListChannelsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListChannelsRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListChannelsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListChannelsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_channels Override in a subclass to manipulate the request or metadata @@ -627,8 +671,10 @@ def post_list_channels( return response def pre_list_clips( - self, request: service.ListClipsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListClipsRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListClipsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListClipsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_clips Override in a subclass to manipulate the request or metadata @@ -648,8 +694,10 @@ def post_list_clips( return response def pre_list_events( - self, request: service.ListEventsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListEventsRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListEventsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListEventsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_events Override in a subclass to manipulate the request or metadata @@ -669,8 +717,10 @@ def post_list_events( return response def pre_list_inputs( - self, request: service.ListInputsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListInputsRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListInputsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListInputsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_inputs Override in a subclass to manipulate the request or metadata @@ -690,8 +740,10 @@ def post_list_inputs( return response def pre_start_channel( - self, request: service.StartChannelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.StartChannelRequest, Sequence[Tuple[str, str]]]: + self, + request: service.StartChannelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.StartChannelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for start_channel Override in a subclass to manipulate the request or metadata @@ -711,8 +763,10 @@ def post_start_channel( return response def pre_stop_channel( - self, request: service.StopChannelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.StopChannelRequest, Sequence[Tuple[str, str]]]: + self, + request: service.StopChannelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.StopChannelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for stop_channel Override in a subclass to manipulate the request or metadata @@ -732,8 +786,10 @@ def post_stop_channel( return response def pre_update_channel( - self, request: service.UpdateChannelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdateChannelRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdateChannelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateChannelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_channel Override in a subclass to manipulate the request or metadata @@ -753,8 +809,10 @@ def post_update_channel( return response def pre_update_input( - self, request: service.UpdateInputRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdateInputRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdateInputRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateInputRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_input Override in a subclass to manipulate the request or metadata @@ -774,8 +832,10 @@ def post_update_input( return response def pre_update_pool( - self, request: service.UpdatePoolRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdatePoolRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdatePoolRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdatePoolRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_pool Override in a subclass to manipulate the request or metadata @@ -797,8 +857,10 @@ def post_update_pool( 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 @@ -820,8 +882,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 @@ -843,8 +907,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 @@ -864,8 +930,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 @@ -885,8 +953,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 @@ -908,8 +978,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 @@ -1109,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create asset method over HTTP. @@ -1120,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: ~.operations_pb2.Operation: @@ -1134,6 +1208,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseCreateAsset._get_http_options() ) + request, metadata = self._interceptor.pre_create_asset(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseCreateAsset._get_transcoded_request( http_options, request @@ -1148,6 +1223,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.CreateAsset", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "CreateAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._CreateAsset._get_response( self._host, @@ -1167,7 +1269,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_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.livestream_v1.LivestreamServiceClient.create_asset", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "CreateAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateChannel( @@ -1206,7 +1330,7 @@ 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 channel method over HTTP. @@ -1217,8 +1341,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1231,6 +1357,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseCreateChannel._get_http_options() ) + request, metadata = self._interceptor.pre_create_channel(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseCreateChannel._get_transcoded_request( http_options, request @@ -1245,6 +1372,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.CreateChannel", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "CreateChannel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._CreateChannel._get_response( self._host, @@ -1264,7 +1418,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_channel(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.livestream_v1.LivestreamServiceClient.create_channel_", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "CreateChannel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateClip( @@ -1302,7 +1478,7 @@ 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 clip method over HTTP. @@ -1313,8 +1489,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1327,6 +1505,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseCreateClip._get_http_options() ) + request, metadata = self._interceptor.pre_create_clip(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseCreateClip._get_transcoded_request( http_options, request @@ -1341,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.CreateClip", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "CreateClip", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._CreateClip._get_response( self._host, @@ -1360,7 +1566,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_clip(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.livestream_v1.LivestreamServiceClient.create_clip", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "CreateClip", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateEvent( @@ -1398,7 +1626,7 @@ 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.Event: r"""Call the create event method over HTTP. @@ -1409,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.Event: @@ -1424,6 +1654,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseCreateEvent._get_http_options() ) + request, metadata = self._interceptor.pre_create_event(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseCreateEvent._get_transcoded_request( http_options, request @@ -1438,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.video.livestream_v1.LivestreamServiceClient.CreateEvent", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "CreateEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._CreateEvent._get_response( self._host, @@ -1459,7 +1717,29 @@ def __call__( pb_resp = resources.Event.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Event.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.livestream_v1.LivestreamServiceClient.create_event", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "CreateEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateInput( @@ -1497,7 +1777,7 @@ 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 input method over HTTP. @@ -1508,8 +1788,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1522,6 +1804,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseCreateInput._get_http_options() ) + request, metadata = self._interceptor.pre_create_input(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseCreateInput._get_transcoded_request( http_options, request @@ -1536,6 +1819,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.CreateInput", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "CreateInput", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._CreateInput._get_response( self._host, @@ -1555,7 +1865,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_input(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.livestream_v1.LivestreamServiceClient.create_input", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "CreateInput", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAsset( @@ -1592,7 +1924,7 @@ 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 asset method over HTTP. @@ -1603,8 +1935,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1617,6 +1951,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseDeleteAsset._get_http_options() ) + request, metadata = self._interceptor.pre_delete_asset(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseDeleteAsset._get_transcoded_request( http_options, request @@ -1627,6 +1962,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.DeleteAsset", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "DeleteAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._DeleteAsset._get_response( self._host, @@ -1645,7 +2007,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_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.livestream_v1.LivestreamServiceClient.delete_asset", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "DeleteAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteChannel( @@ -1683,7 +2067,7 @@ 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 channel method over HTTP. @@ -1694,8 +2078,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1708,6 +2094,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseDeleteChannel._get_http_options() ) + request, metadata = self._interceptor.pre_delete_channel(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseDeleteChannel._get_transcoded_request( http_options, request @@ -1718,6 +2105,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.DeleteChannel", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "DeleteChannel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._DeleteChannel._get_response( self._host, @@ -1736,7 +2150,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_channel(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.livestream_v1.LivestreamServiceClient.delete_channel", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "DeleteChannel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteClip( @@ -1773,7 +2209,7 @@ 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 clip method over HTTP. @@ -1784,8 +2220,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1798,6 +2236,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseDeleteClip._get_http_options() ) + request, metadata = self._interceptor.pre_delete_clip(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseDeleteClip._get_transcoded_request( http_options, request @@ -1808,6 +2247,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.DeleteClip", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "DeleteClip", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._DeleteClip._get_response( self._host, @@ -1826,7 +2292,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_clip(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.livestream_v1.LivestreamServiceClient.delete_clip", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "DeleteClip", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteEvent( @@ -1863,7 +2351,7 @@ 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 event method over HTTP. @@ -1874,13 +2362,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 = ( _BaseLivestreamServiceRestTransport._BaseDeleteEvent._get_http_options() ) + request, metadata = self._interceptor.pre_delete_event(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseDeleteEvent._get_transcoded_request( http_options, request @@ -1891,6 +2382,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.DeleteEvent", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "DeleteEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._DeleteEvent._get_response( self._host, @@ -1940,7 +2458,7 @@ 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 input method over HTTP. @@ -1951,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: ~.operations_pb2.Operation: @@ -1965,6 +2485,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseDeleteInput._get_http_options() ) + request, metadata = self._interceptor.pre_delete_input(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseDeleteInput._get_transcoded_request( http_options, request @@ -1975,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.DeleteInput", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "DeleteInput", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._DeleteInput._get_response( self._host, @@ -1993,7 +2541,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_input(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.livestream_v1.LivestreamServiceClient.delete_input", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "DeleteInput", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAsset( @@ -2030,7 +2600,7 @@ 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.Asset: r"""Call the get asset method over HTTP. @@ -2041,8 +2611,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Asset: @@ -2054,6 +2626,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseGetAsset._get_http_options() ) + request, metadata = self._interceptor.pre_get_asset(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseGetAsset._get_transcoded_request( http_options, request @@ -2064,6 +2637,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.GetAsset", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._GetAsset._get_response( self._host, @@ -2084,7 +2684,29 @@ def __call__( pb_resp = resources.Asset.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Asset.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.livestream_v1.LivestreamServiceClient.get_asset", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetChannel( @@ -2121,7 +2743,7 @@ 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.Channel: r"""Call the get channel method over HTTP. @@ -2132,8 +2754,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Channel: @@ -2151,6 +2775,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseGetChannel._get_http_options() ) + request, metadata = self._interceptor.pre_get_channel(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseGetChannel._get_transcoded_request( http_options, request @@ -2161,6 +2786,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.GetChannel", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetChannel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._GetChannel._get_response( self._host, @@ -2181,7 +2833,29 @@ def __call__( pb_resp = resources.Channel.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_channel(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Channel.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.livestream_v1.LivestreamServiceClient.get_channel", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetChannel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetClip( @@ -2218,7 +2892,7 @@ 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.Clip: r"""Call the get clip method over HTTP. @@ -2229,8 +2903,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Clip: @@ -2245,6 +2921,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseGetClip._get_http_options() ) + request, metadata = self._interceptor.pre_get_clip(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseGetClip._get_transcoded_request( http_options, request @@ -2257,6 +2934,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.GetClip", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetClip", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._GetClip._get_response( self._host, @@ -2277,7 +2981,29 @@ def __call__( pb_resp = resources.Clip.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_clip(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Clip.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.livestream_v1.LivestreamServiceClient.get_clip", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetClip", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEvent( @@ -2314,7 +3040,7 @@ 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.Event: r"""Call the get event method over HTTP. @@ -2325,8 +3051,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Event: @@ -2340,6 +3068,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseGetEvent._get_http_options() ) + request, metadata = self._interceptor.pre_get_event(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseGetEvent._get_transcoded_request( http_options, request @@ -2350,6 +3079,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.GetEvent", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._GetEvent._get_response( self._host, @@ -2370,7 +3126,29 @@ def __call__( pb_resp = resources.Event.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Event.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.livestream_v1.LivestreamServiceClient.get_event", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetInput( @@ -2407,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]]] = (), ) -> resources.Input: r"""Call the get input method over HTTP. @@ -2418,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: ~.resources.Input: @@ -2432,6 +3212,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseGetInput._get_http_options() ) + request, metadata = self._interceptor.pre_get_input(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseGetInput._get_transcoded_request( http_options, request @@ -2442,6 +3223,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.GetInput", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetInput", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._GetInput._get_response( self._host, @@ -2462,7 +3270,29 @@ def __call__( pb_resp = resources.Input.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_input(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Input.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.livestream_v1.LivestreamServiceClient.get_input", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetInput", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetPool( @@ -2499,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]]] = (), ) -> resources.Pool: r"""Call the get pool method over HTTP. @@ -2510,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: ~.resources.Pool: @@ -2529,6 +3361,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseGetPool._get_http_options() ) + request, metadata = self._interceptor.pre_get_pool(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseGetPool._get_transcoded_request( http_options, request @@ -2541,6 +3374,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.GetPool", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetPool", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._GetPool._get_response( self._host, @@ -2561,7 +3421,29 @@ def __call__( pb_resp = resources.Pool.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_pool(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Pool.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.livestream_v1.LivestreamServiceClient.get_pool", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetPool", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAssets( @@ -2598,7 +3480,7 @@ 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.ListAssetsResponse: r"""Call the list assets method over HTTP. @@ -2609,8 +3491,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListAssetsResponse: @@ -2622,6 +3506,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseListAssets._get_http_options() ) + request, metadata = self._interceptor.pre_list_assets(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseListAssets._get_transcoded_request( http_options, request @@ -2632,6 +3517,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.ListAssets", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListAssets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._ListAssets._get_response( self._host, @@ -2652,7 +3564,29 @@ def __call__( pb_resp = service.ListAssetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_assets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListAssetsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.livestream_v1.LivestreamServiceClient.list_assets", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListAssets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListChannels( @@ -2689,7 +3623,7 @@ 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.ListChannelsResponse: r"""Call the list channels method over HTTP. @@ -2700,8 +3634,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListChannelsResponse: @@ -2713,6 +3649,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseListChannels._get_http_options() ) + request, metadata = self._interceptor.pre_list_channels(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseListChannels._get_transcoded_request( http_options, request @@ -2723,6 +3660,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.ListChannels", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListChannels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._ListChannels._get_response( self._host, @@ -2743,7 +3707,29 @@ def __call__( pb_resp = service.ListChannelsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_channels(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListChannelsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.livestream_v1.LivestreamServiceClient.list_channels", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListChannels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListClips( @@ -2780,7 +3766,7 @@ 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.ListClipsResponse: r"""Call the list clips method over HTTP. @@ -2791,8 +3777,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListClipsResponse: @@ -2804,6 +3792,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseListClips._get_http_options() ) + request, metadata = self._interceptor.pre_list_clips(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseListClips._get_transcoded_request( http_options, request @@ -2814,6 +3803,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.ListClips", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListClips", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._ListClips._get_response( self._host, @@ -2834,7 +3850,29 @@ def __call__( pb_resp = service.ListClipsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_clips(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListClipsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.livestream_v1.LivestreamServiceClient.list_clips", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListClips", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEvents( @@ -2871,7 +3909,7 @@ 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.ListEventsResponse: r"""Call the list events method over HTTP. @@ -2882,8 +3920,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListEventsResponse: @@ -2895,6 +3935,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseListEvents._get_http_options() ) + request, metadata = self._interceptor.pre_list_events(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseListEvents._get_transcoded_request( http_options, request @@ -2905,6 +3946,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.ListEvents", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._ListEvents._get_response( self._host, @@ -2925,7 +3993,29 @@ def __call__( pb_resp = service.ListEventsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_events(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListEventsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.livestream_v1.LivestreamServiceClient.list_events", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListInputs( @@ -2962,7 +4052,7 @@ 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.ListInputsResponse: r"""Call the list inputs method over HTTP. @@ -2973,8 +4063,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListInputsResponse: @@ -2986,6 +4078,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseListInputs._get_http_options() ) + request, metadata = self._interceptor.pre_list_inputs(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseListInputs._get_transcoded_request( http_options, request @@ -2996,6 +4089,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.ListInputs", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListInputs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._ListInputs._get_response( self._host, @@ -3016,7 +4136,29 @@ def __call__( pb_resp = service.ListInputsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_inputs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListInputsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.livestream_v1.LivestreamServiceClient.list_inputs", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListInputs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StartChannel( @@ -3054,7 +4196,7 @@ 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 start channel method over HTTP. @@ -3065,8 +4207,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3079,6 +4223,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseStartChannel._get_http_options() ) + request, metadata = self._interceptor.pre_start_channel(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseStartChannel._get_transcoded_request( http_options, request @@ -3093,6 +4238,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.StartChannel", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "StartChannel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._StartChannel._get_response( self._host, @@ -3112,7 +4284,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_start_channel(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.livestream_v1.LivestreamServiceClient.start_channel", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "StartChannel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StopChannel( @@ -3150,7 +4344,7 @@ 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 stop channel method over HTTP. @@ -3161,8 +4355,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3175,6 +4371,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseStopChannel._get_http_options() ) + request, metadata = self._interceptor.pre_stop_channel(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseStopChannel._get_transcoded_request( http_options, request @@ -3189,6 +4386,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.StopChannel", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "StopChannel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._StopChannel._get_response( self._host, @@ -3208,7 +4432,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_stop_channel(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.livestream_v1.LivestreamServiceClient.stop_channel", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "StopChannel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateChannel( @@ -3247,7 +4493,7 @@ 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 channel method over HTTP. @@ -3258,8 +4504,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3272,6 +4520,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseUpdateChannel._get_http_options() ) + request, metadata = self._interceptor.pre_update_channel(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseUpdateChannel._get_transcoded_request( http_options, request @@ -3286,6 +4535,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.UpdateChannel", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "UpdateChannel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._UpdateChannel._get_response( self._host, @@ -3305,7 +4581,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_channel(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.livestream_v1.LivestreamServiceClient.update_channel", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "UpdateChannel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateInput( @@ -3343,7 +4641,7 @@ 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 input method over HTTP. @@ -3354,8 +4652,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3368,6 +4668,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseUpdateInput._get_http_options() ) + request, metadata = self._interceptor.pre_update_input(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseUpdateInput._get_transcoded_request( http_options, request @@ -3382,6 +4683,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.UpdateInput", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "UpdateInput", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._UpdateInput._get_response( self._host, @@ -3401,7 +4729,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_input(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.livestream_v1.LivestreamServiceClient.update_input", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "UpdateInput", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdatePool( @@ -3439,7 +4789,7 @@ 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 pool method over HTTP. @@ -3450,8 +4800,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3464,6 +4816,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseUpdatePool._get_http_options() ) + request, metadata = self._interceptor.pre_update_pool(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseUpdatePool._get_transcoded_request( http_options, request @@ -3478,6 +4831,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.UpdatePool", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "UpdatePool", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._UpdatePool._get_response( self._host, @@ -3497,7 +4877,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_pool(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.livestream_v1.LivestreamServiceClient.update_pool", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "UpdatePool", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -3730,7 +5132,7 @@ 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. @@ -3740,8 +5142,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -3750,6 +5154,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -3760,6 +5165,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._GetLocation._get_response( self._host, @@ -3779,6 +5211,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.video.livestream_v1.LivestreamServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3820,7 +5273,7 @@ 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. @@ -3830,8 +5283,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -3840,6 +5295,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -3850,6 +5306,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._ListLocations._get_response( self._host, @@ -3869,6 +5352,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.video.livestream_v1.LivestreamServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3911,7 +5415,7 @@ 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. @@ -3921,13 +5425,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 = ( _BaseLivestreamServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -3944,6 +5451,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._CancelOperation._get_response( self._host, @@ -4001,7 +5535,7 @@ 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. @@ -4011,13 +5545,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 = ( _BaseLivestreamServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -4030,6 +5567,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._DeleteOperation._get_response( self._host, @@ -4085,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -4095,8 +5659,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -4105,6 +5671,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -4115,6 +5682,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._GetOperation._get_response( self._host, @@ -4134,6 +5728,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.video.livestream_v1.LivestreamServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4175,7 +5790,7 @@ 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. @@ -4185,8 +5800,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -4195,6 +5812,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -4205,6 +5823,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.livestream_v1.LivestreamServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._ListOperations._get_response( self._host, @@ -4224,6 +5869,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.video.livestream_v1.LivestreamServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/snippet_metadata_google.cloud.video.livestream.v1.json b/packages/google-cloud-video-live-stream/samples/generated_samples/snippet_metadata_google.cloud.video.livestream.v1.json index 570561e03734..6c0ad77a25a4 100644 --- a/packages/google-cloud-video-live-stream/samples/generated_samples/snippet_metadata_google.cloud.video.livestream.v1.json +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/snippet_metadata_google.cloud.video.livestream.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-video-live-stream", - "version": "1.9.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", @@ -409,7 +409,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -497,7 +497,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -586,7 +586,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Event", @@ -674,7 +674,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Event", @@ -763,7 +763,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -851,7 +851,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -932,7 +932,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1012,7 +1012,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1093,7 +1093,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1173,7 +1173,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1254,7 +1254,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1334,7 +1334,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1415,7 +1415,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_event" @@ -1492,7 +1492,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_event" @@ -1570,7 +1570,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1650,7 +1650,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1731,7 +1731,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Asset", @@ -1811,7 +1811,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Asset", @@ -1892,7 +1892,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Channel", @@ -1972,7 +1972,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Channel", @@ -2053,7 +2053,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Clip", @@ -2133,7 +2133,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Clip", @@ -2214,7 +2214,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Event", @@ -2294,7 +2294,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Event", @@ -2375,7 +2375,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Input", @@ -2455,7 +2455,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Input", @@ -2536,7 +2536,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Pool", @@ -2616,7 +2616,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Pool", @@ -2697,7 +2697,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListAssetsAsyncPager", @@ -2777,7 +2777,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListAssetsPager", @@ -2858,7 +2858,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListChannelsAsyncPager", @@ -2938,7 +2938,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListChannelsPager", @@ -3019,7 +3019,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListClipsAsyncPager", @@ -3099,7 +3099,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListClipsPager", @@ -3180,7 +3180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListEventsAsyncPager", @@ -3260,7 +3260,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListEventsPager", @@ -3341,7 +3341,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListInputsAsyncPager", @@ -3421,7 +3421,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListInputsPager", @@ -3502,7 +3502,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3582,7 +3582,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3663,7 +3663,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3743,7 +3743,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3828,7 +3828,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3912,7 +3912,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3997,7 +3997,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4081,7 +4081,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4166,7 +4166,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4250,7 +4250,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-video-live-stream/tests/unit/gapic/live_stream_v1/test_livestream_service.py b/packages/google-cloud-video-live-stream/tests/unit/gapic/live_stream_v1/test_livestream_service.py index 36bd6770f028..080c26abea44 100644 --- a/packages/google-cloud-video-live-stream/tests/unit/gapic/live_stream_v1/test_livestream_service.py +++ b/packages/google-cloud-video-live-stream/tests/unit/gapic/live_stream_v1/test_livestream_service.py @@ -10864,6 +10864,7 @@ def test_create_channel_rest_required_fields(request_type=service.CreateChannelR response_value._content = json_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_channel(request) @@ -10929,6 +10930,7 @@ def test_create_channel_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_channel(**mock_args) @@ -11068,6 +11070,7 @@ def test_list_channels_rest_required_fields(request_type=service.ListChannelsReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_channels(request) @@ -11123,6 +11126,7 @@ def test_list_channels_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_channels(**mock_args) @@ -11312,6 +11316,7 @@ def test_get_channel_rest_required_fields(request_type=service.GetChannelRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_channel(request) @@ -11357,6 +11362,7 @@ def test_get_channel_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_channel(**mock_args) @@ -11493,6 +11499,7 @@ def test_delete_channel_rest_required_fields(request_type=service.DeleteChannelR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_channel(request) @@ -11544,6 +11551,7 @@ def test_delete_channel_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_channel(**mock_args) @@ -11676,6 +11684,7 @@ def test_update_channel_rest_required_fields(request_type=service.UpdateChannelR response_value._content = json_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_channel(request) @@ -11730,6 +11739,7 @@ def test_update_channel_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_channel(**mock_args) @@ -11862,6 +11872,7 @@ def test_start_channel_rest_required_fields(request_type=service.StartChannelReq response_value._content = json_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_channel(request) @@ -11905,6 +11916,7 @@ def test_start_channel_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_channel(**mock_args) @@ -12036,6 +12048,7 @@ def test_stop_channel_rest_required_fields(request_type=service.StopChannelReque response_value._content = json_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_channel(request) @@ -12079,6 +12092,7 @@ def test_stop_channel_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_channel(**mock_args) @@ -12224,6 +12238,7 @@ def test_create_input_rest_required_fields(request_type=service.CreateInputReque response_value._content = json_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_input(request) @@ -12289,6 +12304,7 @@ def test_create_input_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_input(**mock_args) @@ -12428,6 +12444,7 @@ def test_list_inputs_rest_required_fields(request_type=service.ListInputsRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_inputs(request) @@ -12483,6 +12500,7 @@ def test_list_inputs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_inputs(**mock_args) @@ -12672,6 +12690,7 @@ def test_get_input_rest_required_fields(request_type=service.GetInputRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_input(request) @@ -12717,6 +12736,7 @@ def test_get_input_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_input(**mock_args) @@ -12848,6 +12868,7 @@ def test_delete_input_rest_required_fields(request_type=service.DeleteInputReque response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_input(request) @@ -12891,6 +12912,7 @@ def test_delete_input_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_input(**mock_args) @@ -13023,6 +13045,7 @@ def test_update_input_rest_required_fields(request_type=service.UpdateInputReque response_value._content = json_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_input(request) @@ -13077,6 +13100,7 @@ def test_update_input_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_input(**mock_args) @@ -13222,6 +13246,7 @@ def test_create_event_rest_required_fields(request_type=service.CreateEventReque response_value._content = json_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_event(request) @@ -13291,6 +13316,7 @@ def test_create_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.create_event(**mock_args) @@ -13431,6 +13457,7 @@ def test_list_events_rest_required_fields(request_type=service.ListEventsRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_events(request) @@ -13488,6 +13515,7 @@ def test_list_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_events(**mock_args) @@ -13680,6 +13708,7 @@ def test_get_event_rest_required_fields(request_type=service.GetEventRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_event(request) @@ -13727,6 +13756,7 @@ def test_get_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_event(**mock_args) @@ -13855,6 +13885,7 @@ def test_delete_event_rest_required_fields(request_type=service.DeleteEventReque response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_event(request) @@ -13900,6 +13931,7 @@ def test_delete_event_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_event(**mock_args) @@ -14038,6 +14070,7 @@ def test_list_clips_rest_required_fields(request_type=service.ListClipsRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_clips(request) @@ -14095,6 +14128,7 @@ def test_list_clips_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_clips(**mock_args) @@ -14287,6 +14321,7 @@ def test_get_clip_rest_required_fields(request_type=service.GetClipRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_clip(request) @@ -14334,6 +14369,7 @@ def test_get_clip_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_clip(**mock_args) @@ -14479,6 +14515,7 @@ def test_create_clip_rest_required_fields(request_type=service.CreateClipRequest response_value._content = json_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_clip(request) @@ -14546,6 +14583,7 @@ def test_create_clip_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_clip(**mock_args) @@ -14680,6 +14718,7 @@ def test_delete_clip_rest_required_fields(request_type=service.DeleteClipRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_clip(request) @@ -14725,6 +14764,7 @@ def test_delete_clip_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_clip(**mock_args) @@ -14870,6 +14910,7 @@ def test_create_asset_rest_required_fields(request_type=service.CreateAssetReque response_value._content = json_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_asset(request) @@ -14935,6 +14976,7 @@ def test_create_asset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_asset(**mock_args) @@ -15068,6 +15110,7 @@ def test_delete_asset_rest_required_fields(request_type=service.DeleteAssetReque response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_asset(request) @@ -15111,6 +15154,7 @@ def test_delete_asset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_asset(**mock_args) @@ -15239,6 +15283,7 @@ def test_get_asset_rest_required_fields(request_type=service.GetAssetRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_asset(request) @@ -15284,6 +15329,7 @@ def test_get_asset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_asset(**mock_args) @@ -15421,6 +15467,7 @@ def test_list_assets_rest_required_fields(request_type=service.ListAssetsRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_assets(request) @@ -15476,6 +15523,7 @@ def test_list_assets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_assets(**mock_args) @@ -15665,6 +15713,7 @@ def test_get_pool_rest_required_fields(request_type=service.GetPoolRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_pool(request) @@ -15710,6 +15759,7 @@ def test_get_pool_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_pool(**mock_args) @@ -15842,6 +15892,7 @@ def test_update_pool_rest_required_fields(request_type=service.UpdatePoolRequest response_value._content = json_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_pool(request) @@ -15896,6 +15947,7 @@ def test_update_pool_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_pool(**mock_args) @@ -17307,6 +17359,7 @@ def test_create_channel_rest_bad_request(request_type=service.CreateChannelReque response_value.status_code = 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_channel(request) @@ -17543,6 +17596,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_channel(request) # Establish that the response is the type that we expect. @@ -17582,6 +17636,7 @@ def test_create_channel_rest_interceptors(null_interceptor): req.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 @@ -17624,6 +17679,7 @@ def test_list_channels_rest_bad_request(request_type=service.ListChannelsRequest response_value.status_code = 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_channels(request) @@ -17660,6 +17716,7 @@ def test_list_channels_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_channels(request) # Establish that the response is the type that we expect. @@ -17699,6 +17756,7 @@ def test_list_channels_rest_interceptors(null_interceptor): req.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.ListChannelsResponse.to_json( service.ListChannelsResponse() ) @@ -17743,6 +17801,7 @@ def test_get_channel_rest_bad_request(request_type=service.GetChannelRequest): response_value.status_code = 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_channel(request) @@ -17780,6 +17839,7 @@ def test_get_channel_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_channel(request) # Establish that the response is the type that we expect. @@ -17820,6 +17880,7 @@ def test_get_channel_rest_interceptors(null_interceptor): req.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.Channel.to_json(resources.Channel()) req.return_value.content = return_value @@ -17862,6 +17923,7 @@ def test_delete_channel_rest_bad_request(request_type=service.DeleteChannelReque response_value.status_code = 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_channel(request) @@ -17892,6 +17954,7 @@ def test_delete_channel_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_channel(request) # Establish that the response is the type that we expect. @@ -17931,6 +17994,7 @@ def test_delete_channel_rest_interceptors(null_interceptor): req.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 @@ -17975,6 +18039,7 @@ def test_update_channel_rest_bad_request(request_type=service.UpdateChannelReque response_value.status_code = 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_channel(request) @@ -18213,6 +18278,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_channel(request) # Establish that the response is the type that we expect. @@ -18252,6 +18318,7 @@ def test_update_channel_rest_interceptors(null_interceptor): req.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 @@ -18294,6 +18361,7 @@ def test_start_channel_rest_bad_request(request_type=service.StartChannelRequest response_value.status_code = 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_channel(request) @@ -18324,6 +18392,7 @@ def test_start_channel_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_channel(request) # Establish that the response is the type that we expect. @@ -18363,6 +18432,7 @@ def test_start_channel_rest_interceptors(null_interceptor): req.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 @@ -18405,6 +18475,7 @@ def test_stop_channel_rest_bad_request(request_type=service.StopChannelRequest): response_value.status_code = 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_channel(request) @@ -18435,6 +18506,7 @@ def test_stop_channel_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_channel(request) # Establish that the response is the type that we expect. @@ -18474,6 +18546,7 @@ def test_stop_channel_rest_interceptors(null_interceptor): req.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 @@ -18516,6 +18589,7 @@ def test_create_input_rest_bad_request(request_type=service.CreateInputRequest): response_value.status_code = 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_input(request) @@ -18665,6 +18739,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_input(request) # Establish that the response is the type that we expect. @@ -18704,6 +18779,7 @@ def test_create_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -18746,6 +18822,7 @@ def test_list_inputs_rest_bad_request(request_type=service.ListInputsRequest): response_value.status_code = 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_inputs(request) @@ -18782,6 +18859,7 @@ def test_list_inputs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_inputs(request) # Establish that the response is the type that we expect. @@ -18821,6 +18899,7 @@ def test_list_inputs_rest_interceptors(null_interceptor): req.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.ListInputsResponse.to_json(service.ListInputsResponse()) req.return_value.content = return_value @@ -18863,6 +18942,7 @@ def test_get_input_rest_bad_request(request_type=service.GetInputRequest): response_value.status_code = 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_input(request) @@ -18901,6 +18981,7 @@ def test_get_input_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_input(request) # Establish that the response is the type that we expect. @@ -18942,6 +19023,7 @@ def test_get_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 = resources.Input.to_json(resources.Input()) req.return_value.content = return_value @@ -18984,6 +19066,7 @@ def test_delete_input_rest_bad_request(request_type=service.DeleteInputRequest): response_value.status_code = 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_input(request) @@ -19014,6 +19097,7 @@ def test_delete_input_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_input(request) # Establish that the response is the type that we expect. @@ -19053,6 +19137,7 @@ def test_delete_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -19097,6 +19182,7 @@ def test_update_input_rest_bad_request(request_type=service.UpdateInputRequest): response_value.status_code = 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_input(request) @@ -19248,6 +19334,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_input(request) # Establish that the response is the type that we expect. @@ -19287,6 +19374,7 @@ def test_update_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -19329,6 +19417,7 @@ def test_create_event_rest_bad_request(request_type=service.CreateEventRequest): response_value.status_code = 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_event(request) @@ -19458,6 +19547,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_event(request) # Establish that the response is the type that we expect. @@ -19498,6 +19588,7 @@ def test_create_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 = resources.Event.to_json(resources.Event()) req.return_value.content = return_value @@ -19540,6 +19631,7 @@ def test_list_events_rest_bad_request(request_type=service.ListEventsRequest): response_value.status_code = 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_events(request) @@ -19576,6 +19668,7 @@ def test_list_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_events(request) # Establish that the response is the type that we expect. @@ -19615,6 +19708,7 @@ def test_list_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 = service.ListEventsResponse.to_json(service.ListEventsResponse()) req.return_value.content = return_value @@ -19659,6 +19753,7 @@ def test_get_event_rest_bad_request(request_type=service.GetEventRequest): response_value.status_code = 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_event(request) @@ -19698,6 +19793,7 @@ def test_get_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_event(request) # Establish that the response is the type that we expect. @@ -19738,6 +19834,7 @@ def test_get_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 = resources.Event.to_json(resources.Event()) req.return_value.content = return_value @@ -19782,6 +19879,7 @@ def test_delete_event_rest_bad_request(request_type=service.DeleteEventRequest): response_value.status_code = 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_event(request) @@ -19814,6 +19912,7 @@ def test_delete_event_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_event(request) # Establish that the response is the type that we expect. @@ -19848,6 +19947,7 @@ def test_delete_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"} request = service.DeleteEventRequest() metadata = [ @@ -19886,6 +19986,7 @@ def test_list_clips_rest_bad_request(request_type=service.ListClipsRequest): response_value.status_code = 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_clips(request) @@ -19922,6 +20023,7 @@ def test_list_clips_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_clips(request) # Establish that the response is the type that we expect. @@ -19961,6 +20063,7 @@ def test_list_clips_rest_interceptors(null_interceptor): req.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.ListClipsResponse.to_json(service.ListClipsResponse()) req.return_value.content = return_value @@ -20005,6 +20108,7 @@ def test_get_clip_rest_bad_request(request_type=service.GetClipRequest): response_value.status_code = 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_clip(request) @@ -20044,6 +20148,7 @@ def test_get_clip_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_clip(request) # Establish that the response is the type that we expect. @@ -20084,6 +20189,7 @@ def test_get_clip_rest_interceptors(null_interceptor): req.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.Clip.to_json(resources.Clip()) req.return_value.content = return_value @@ -20126,6 +20232,7 @@ def test_create_clip_rest_bad_request(request_type=service.CreateClipRequest): response_value.status_code = 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_clip(request) @@ -20246,6 +20353,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_clip(request) # Establish that the response is the type that we expect. @@ -20285,6 +20393,7 @@ def test_create_clip_rest_interceptors(null_interceptor): req.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 @@ -20329,6 +20438,7 @@ def test_delete_clip_rest_bad_request(request_type=service.DeleteClipRequest): response_value.status_code = 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_clip(request) @@ -20361,6 +20471,7 @@ def test_delete_clip_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_clip(request) # Establish that the response is the type that we expect. @@ -20400,6 +20511,7 @@ def test_delete_clip_rest_interceptors(null_interceptor): req.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 @@ -20442,6 +20554,7 @@ def test_create_asset_rest_bad_request(request_type=service.CreateAssetRequest): response_value.status_code = 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_asset(request) @@ -20559,6 +20672,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_asset(request) # Establish that the response is the type that we expect. @@ -20598,6 +20712,7 @@ def test_create_asset_rest_interceptors(null_interceptor): req.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 @@ -20640,6 +20755,7 @@ def test_delete_asset_rest_bad_request(request_type=service.DeleteAssetRequest): response_value.status_code = 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_asset(request) @@ -20670,6 +20786,7 @@ def test_delete_asset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_asset(request) # Establish that the response is the type that we expect. @@ -20709,6 +20826,7 @@ def test_delete_asset_rest_interceptors(null_interceptor): req.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 @@ -20751,6 +20869,7 @@ def test_get_asset_rest_bad_request(request_type=service.GetAssetRequest): response_value.status_code = 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_asset(request) @@ -20788,6 +20907,7 @@ def test_get_asset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_asset(request) # Establish that the response is the type that we expect. @@ -20828,6 +20948,7 @@ def test_get_asset_rest_interceptors(null_interceptor): req.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.Asset.to_json(resources.Asset()) req.return_value.content = return_value @@ -20870,6 +20991,7 @@ def test_list_assets_rest_bad_request(request_type=service.ListAssetsRequest): response_value.status_code = 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_assets(request) @@ -20906,6 +21028,7 @@ def test_list_assets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_assets(request) # Establish that the response is the type that we expect. @@ -20945,6 +21068,7 @@ def test_list_assets_rest_interceptors(null_interceptor): req.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.ListAssetsResponse.to_json(service.ListAssetsResponse()) req.return_value.content = return_value @@ -20987,6 +21111,7 @@ def test_get_pool_rest_bad_request(request_type=service.GetPoolRequest): response_value.status_code = 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_pool(request) @@ -21022,6 +21147,7 @@ def test_get_pool_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_pool(request) # Establish that the response is the type that we expect. @@ -21060,6 +21186,7 @@ def test_get_pool_rest_interceptors(null_interceptor): req.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.Pool.to_json(resources.Pool()) req.return_value.content = return_value @@ -21104,6 +21231,7 @@ def test_update_pool_rest_bad_request(request_type=service.UpdatePoolRequest): response_value.status_code = 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_pool(request) @@ -21210,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_pool(request) # Establish that the response is the type that we expect. @@ -21249,6 +21378,7 @@ def test_update_pool_rest_interceptors(null_interceptor): req.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 @@ -21293,6 +21423,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) @@ -21323,6 +21454,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) @@ -21351,6 +21483,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) @@ -21381,6 +21514,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) @@ -21411,6 +21545,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) @@ -21441,6 +21576,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) @@ -21471,6 +21607,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) @@ -21501,6 +21638,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) @@ -21531,6 +21669,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) @@ -21561,6 +21700,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) @@ -21591,6 +21731,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) @@ -21621,6 +21762,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-video-stitcher/google/cloud/video/stitcher/gapic_version.py b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher/gapic_version.py index 747954cc02fd..558c8aab67c5 100644 --- a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher/gapic_version.py +++ b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.7.14" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/gapic_version.py b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/gapic_version.py index 747954cc02fd..558c8aab67c5 100644 --- a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/gapic_version.py +++ b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.7.14" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/async_client.py b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/async_client.py index 31b08aa5ae8c..03454170289d 100644 --- a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/async_client.py +++ b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_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, VideoStitcherServiceTransport from .transports.grpc_asyncio import VideoStitcherServiceGrpcAsyncIOTransport +try: + from google.api_core import client_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 VideoStitcherServiceAsyncClient: """Video-On-Demand content stitching API allows you to insert @@ -315,6 +325,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.video.stitcher_v1.VideoStitcherServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "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.video.stitcher.v1.VideoStitcherService", + "credentialsType": None, + }, + ) + async def create_cdn_key( self, request: Optional[ @@ -326,7 +358,7 @@ async def create_cdn_key( cdn_key_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 CDN key. @@ -398,8 +430,10 @@ async def sample_create_cdn_key(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -477,7 +511,7 @@ async def list_cdn_keys( 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.ListCdnKeysAsyncPager: r"""Lists all CDN keys in the specified project and location. @@ -524,8 +558,10 @@ async def sample_list_cdn_keys(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListCdnKeysAsyncPager: @@ -600,7 +636,7 @@ async def get_cdn_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]]] = (), ) -> cdn_keys.CdnKey: r"""Returns the specified CDN key. @@ -645,8 +681,10 @@ async def sample_get_cdn_key(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.stitcher_v1.types.CdnKey: @@ -711,7 +749,7 @@ async def delete_cdn_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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the specified CDN key. @@ -760,8 +798,10 @@ async def sample_delete_cdn_key(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -843,7 +883,7 @@ async def update_cdn_key( 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 CDN key. Only update fields specified in the call method body. @@ -899,8 +939,10 @@ async def sample_update_cdn_key(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -979,7 +1021,7 @@ async def create_vod_session( vod_session: Optional[sessions.VodSession] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> sessions.VodSession: r"""Creates a client side playback VOD session and returns the full tracking and playback metadata of the @@ -1037,8 +1079,10 @@ async def sample_create_vod_session(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.stitcher_v1.types.VodSession: @@ -1104,7 +1148,7 @@ async def get_vod_session( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> sessions.VodSession: r"""Returns the full tracking, playback metadata, and relevant ad-ops logs for the specified VOD session. @@ -1150,8 +1194,10 @@ async def sample_get_vod_session(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.stitcher_v1.types.VodSession: @@ -1215,7 +1261,7 @@ async def list_vod_stitch_details( 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.ListVodStitchDetailsAsyncPager: r"""Returns a list of detailed stitching information of the specified VOD session. @@ -1262,8 +1308,10 @@ async def sample_list_vod_stitch_details(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodStitchDetailsAsyncPager: @@ -1340,7 +1388,7 @@ async def get_vod_stitch_detail( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> stitch_details.VodStitchDetail: r"""Returns the specified stitching information for the specified VOD session. @@ -1386,8 +1434,10 @@ async def sample_get_vod_stitch_detail(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.stitcher_v1.types.VodStitchDetail: @@ -1453,7 +1503,7 @@ async def list_vod_ad_tag_details( 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.ListVodAdTagDetailsAsyncPager: r"""Return the list of ad tag details for the specified VOD session. @@ -1500,8 +1550,10 @@ async def sample_list_vod_ad_tag_details(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodAdTagDetailsAsyncPager: @@ -1578,7 +1630,7 @@ async def get_vod_ad_tag_detail( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ad_tag_details.VodAdTagDetail: r"""Returns the specified ad tag detail for the specified VOD session. @@ -1624,8 +1676,10 @@ async def sample_get_vod_ad_tag_detail(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.stitcher_v1.types.VodAdTagDetail: @@ -1691,7 +1745,7 @@ async def list_live_ad_tag_details( 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.ListLiveAdTagDetailsAsyncPager: r"""Return the list of ad tag details for the specified live session. @@ -1737,8 +1791,10 @@ async def sample_list_live_ad_tag_details(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveAdTagDetailsAsyncPager: @@ -1815,7 +1871,7 @@ async def get_live_ad_tag_detail( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ad_tag_details.LiveAdTagDetail: r"""Returns the specified ad tag detail for the specified live session. @@ -1860,8 +1916,10 @@ async def sample_get_live_ad_tag_detail(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.stitcher_v1.types.LiveAdTagDetail: @@ -1929,7 +1987,7 @@ async def create_slate( slate_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 slate. @@ -1996,8 +2054,10 @@ async def sample_create_slate(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2073,7 +2133,7 @@ async def list_slates( 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.ListSlatesAsyncPager: r"""Lists all slates in the specified project and location. @@ -2119,8 +2179,10 @@ async def sample_list_slates(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListSlatesAsyncPager: @@ -2195,7 +2257,7 @@ async def get_slate( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> slates.Slate: r"""Returns the specified slate. @@ -2240,8 +2302,10 @@ async def sample_get_slate(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.stitcher_v1.types.Slate: @@ -2303,7 +2367,7 @@ async def update_slate( 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 slate. @@ -2358,8 +2422,10 @@ async def sample_update_slate(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2437,7 +2503,7 @@ async def delete_slate( name: Optional[str] = None, retry: OptionalRetry = gapic_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 slate. @@ -2486,8 +2552,10 @@ async def sample_delete_slate(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2569,7 +2637,7 @@ async def create_live_session( live_session: Optional[sessions.LiveSession] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> sessions.LiveSession: r"""Creates a new live session. @@ -2625,8 +2693,10 @@ async def sample_create_live_session(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.stitcher_v1.types.LiveSession: @@ -2693,7 +2763,7 @@ async def get_live_session( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> sessions.LiveSession: r"""Returns the details for the specified live session. @@ -2737,8 +2807,10 @@ async def sample_get_live_session(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.stitcher_v1.types.LiveSession: @@ -2805,7 +2877,7 @@ async def create_live_config( live_config_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"""Registers the live config with the provided unique ID in the specified region. @@ -2875,8 +2947,10 @@ async def sample_create_live_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: @@ -2954,7 +3028,7 @@ async def list_live_configs( 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.ListLiveConfigsAsyncPager: r"""Lists all live configs managed by the Video Stitcher that belong to the specified project and region. @@ -3001,8 +3075,10 @@ async def sample_list_live_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.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveConfigsAsyncPager: @@ -3079,7 +3155,7 @@ async def get_live_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> live_configs.LiveConfig: r"""Returns the specified live config managed by the Video Stitcher service. @@ -3125,8 +3201,10 @@ async def sample_get_live_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.cloud.video.stitcher_v1.types.LiveConfig: @@ -3189,7 +3267,7 @@ async def delete_live_config( name: Optional[str] = None, retry: OptionalRetry = gapic_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 live config. @@ -3238,8 +3316,10 @@ async def sample_delete_live_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: @@ -3321,7 +3401,7 @@ async def update_live_config( 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 LiveConfig. Only update fields specified in the call method body. @@ -3383,8 +3463,10 @@ async def sample_update_live_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: @@ -3464,7 +3546,7 @@ async def create_vod_config( vod_config_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"""Registers the VOD config with the provided unique ID in the specified region. @@ -3534,8 +3616,10 @@ async def sample_create_vod_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: @@ -3613,7 +3697,7 @@ async def list_vod_configs( 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.ListVodConfigsAsyncPager: r"""Lists all VOD configs managed by the Video Stitcher API that belong to the specified project and region. @@ -3660,8 +3744,10 @@ async def sample_list_vod_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.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodConfigsAsyncPager: @@ -3738,7 +3824,7 @@ async def get_vod_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vod_configs.VodConfig: r"""Returns the specified VOD config managed by the Video Stitcher API service. @@ -3784,8 +3870,10 @@ async def sample_get_vod_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.cloud.video.stitcher_v1.types.VodConfig: @@ -3848,7 +3936,7 @@ async def delete_vod_config( name: Optional[str] = None, retry: OptionalRetry = gapic_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 VOD config. @@ -3897,8 +3985,10 @@ async def sample_delete_vod_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: @@ -3980,7 +4070,7 @@ async def update_vod_config( 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 VOD config. Only update fields specified in the call method body. @@ -4042,8 +4132,10 @@ async def sample_update_vod_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: @@ -4118,7 +4210,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. @@ -4129,8 +4221,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. @@ -4171,7 +4265,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. @@ -4182,8 +4276,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. @@ -4224,7 +4320,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. @@ -4240,8 +4336,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 """ @@ -4278,7 +4376,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. @@ -4293,8 +4391,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 """ diff --git a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/client.py b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/client.py index bf3ceecd8ddf..1178e6163405 100644 --- a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/client.py +++ b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_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 @@ -787,6 +797,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( @@ -853,6 +867,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.video.stitcher_v1.VideoStitcherServiceClient`.", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "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.video.stitcher.v1.VideoStitcherService", + "credentialsType": None, + }, + ) + def create_cdn_key( self, request: Optional[ @@ -864,7 +901,7 @@ def create_cdn_key( cdn_key_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 CDN key. @@ -936,8 +973,10 @@ def sample_create_cdn_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.operation.Operation: @@ -1012,7 +1051,7 @@ def list_cdn_keys( 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.ListCdnKeysPager: r"""Lists all CDN keys in the specified project and location. @@ -1059,8 +1098,10 @@ def sample_list_cdn_keys(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListCdnKeysPager: @@ -1132,7 +1173,7 @@ def get_cdn_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]]] = (), ) -> cdn_keys.CdnKey: r"""Returns the specified CDN key. @@ -1177,8 +1218,10 @@ def sample_get_cdn_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.cloud.video.stitcher_v1.types.CdnKey: @@ -1240,7 +1283,7 @@ def delete_cdn_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]]] = (), ) -> operation.Operation: r"""Deletes the specified CDN key. @@ -1289,8 +1332,10 @@ def sample_delete_cdn_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.operation.Operation: @@ -1369,7 +1414,7 @@ def update_cdn_key( 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 CDN key. Only update fields specified in the call method body. @@ -1425,8 +1470,10 @@ def sample_update_cdn_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.operation.Operation: @@ -1502,7 +1549,7 @@ def create_vod_session( vod_session: Optional[sessions.VodSession] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> sessions.VodSession: r"""Creates a client side playback VOD session and returns the full tracking and playback metadata of the @@ -1560,8 +1607,10 @@ def sample_create_vod_session(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.stitcher_v1.types.VodSession: @@ -1624,7 +1673,7 @@ def get_vod_session( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> sessions.VodSession: r"""Returns the full tracking, playback metadata, and relevant ad-ops logs for the specified VOD session. @@ -1670,8 +1719,10 @@ def sample_get_vod_session(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.stitcher_v1.types.VodSession: @@ -1732,7 +1783,7 @@ def list_vod_stitch_details( 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.ListVodStitchDetailsPager: r"""Returns a list of detailed stitching information of the specified VOD session. @@ -1779,8 +1830,10 @@ def sample_list_vod_stitch_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: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodStitchDetailsPager: @@ -1854,7 +1907,7 @@ def get_vod_stitch_detail( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> stitch_details.VodStitchDetail: r"""Returns the specified stitching information for the specified VOD session. @@ -1900,8 +1953,10 @@ def sample_get_vod_stitch_detail(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.stitcher_v1.types.VodStitchDetail: @@ -1964,7 +2019,7 @@ def list_vod_ad_tag_details( 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.ListVodAdTagDetailsPager: r"""Return the list of ad tag details for the specified VOD session. @@ -2011,8 +2066,10 @@ def sample_list_vod_ad_tag_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: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodAdTagDetailsPager: @@ -2086,7 +2143,7 @@ def get_vod_ad_tag_detail( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ad_tag_details.VodAdTagDetail: r"""Returns the specified ad tag detail for the specified VOD session. @@ -2132,8 +2189,10 @@ def sample_get_vod_ad_tag_detail(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.stitcher_v1.types.VodAdTagDetail: @@ -2196,7 +2255,7 @@ def list_live_ad_tag_details( 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.ListLiveAdTagDetailsPager: r"""Return the list of ad tag details for the specified live session. @@ -2242,8 +2301,10 @@ def sample_list_live_ad_tag_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: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveAdTagDetailsPager: @@ -2317,7 +2378,7 @@ def get_live_ad_tag_detail( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ad_tag_details.LiveAdTagDetail: r"""Returns the specified ad tag detail for the specified live session. @@ -2362,8 +2423,10 @@ def sample_get_live_ad_tag_detail(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.stitcher_v1.types.LiveAdTagDetail: @@ -2428,7 +2491,7 @@ def create_slate( slate_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 slate. @@ -2495,8 +2558,10 @@ def sample_create_slate(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2569,7 +2634,7 @@ def list_slates( 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.ListSlatesPager: r"""Lists all slates in the specified project and location. @@ -2615,8 +2680,10 @@ def sample_list_slates(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListSlatesPager: @@ -2688,7 +2755,7 @@ def get_slate( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> slates.Slate: r"""Returns the specified slate. @@ -2733,8 +2800,10 @@ def sample_get_slate(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.stitcher_v1.types.Slate: @@ -2793,7 +2862,7 @@ def update_slate( 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 slate. @@ -2848,8 +2917,10 @@ def sample_update_slate(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2924,7 +2995,7 @@ def delete_slate( name: Optional[str] = None, retry: OptionalRetry = gapic_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 slate. @@ -2973,8 +3044,10 @@ def sample_delete_slate(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3053,7 +3126,7 @@ def create_live_session( live_session: Optional[sessions.LiveSession] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> sessions.LiveSession: r"""Creates a new live session. @@ -3109,8 +3182,10 @@ def sample_create_live_session(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.stitcher_v1.types.LiveSession: @@ -3174,7 +3249,7 @@ def get_live_session( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> sessions.LiveSession: r"""Returns the details for the specified live session. @@ -3218,8 +3293,10 @@ def sample_get_live_session(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.stitcher_v1.types.LiveSession: @@ -3283,7 +3360,7 @@ def create_live_config( live_config_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"""Registers the live config with the provided unique ID in the specified region. @@ -3353,8 +3430,10 @@ def sample_create_live_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: @@ -3429,7 +3508,7 @@ def list_live_configs( 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.ListLiveConfigsPager: r"""Lists all live configs managed by the Video Stitcher that belong to the specified project and region. @@ -3476,8 +3555,10 @@ def sample_list_live_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.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveConfigsPager: @@ -3551,7 +3632,7 @@ def get_live_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> live_configs.LiveConfig: r"""Returns the specified live config managed by the Video Stitcher service. @@ -3597,8 +3678,10 @@ def sample_get_live_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.video.stitcher_v1.types.LiveConfig: @@ -3658,7 +3741,7 @@ def delete_live_config( name: Optional[str] = None, retry: OptionalRetry = gapic_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 live config. @@ -3707,8 +3790,10 @@ def sample_delete_live_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: @@ -3787,7 +3872,7 @@ def update_live_config( 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 LiveConfig. Only update fields specified in the call method body. @@ -3849,8 +3934,10 @@ def sample_update_live_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: @@ -3927,7 +4014,7 @@ def create_vod_config( vod_config_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"""Registers the VOD config with the provided unique ID in the specified region. @@ -3997,8 +4084,10 @@ def sample_create_vod_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: @@ -4073,7 +4162,7 @@ def list_vod_configs( 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.ListVodConfigsPager: r"""Lists all VOD configs managed by the Video Stitcher API that belong to the specified project and region. @@ -4120,8 +4209,10 @@ def sample_list_vod_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.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodConfigsPager: @@ -4195,7 +4286,7 @@ def get_vod_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vod_configs.VodConfig: r"""Returns the specified VOD config managed by the Video Stitcher API service. @@ -4241,8 +4332,10 @@ def sample_get_vod_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.video.stitcher_v1.types.VodConfig: @@ -4302,7 +4395,7 @@ def delete_vod_config( name: Optional[str] = None, retry: OptionalRetry = gapic_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 VOD config. @@ -4351,8 +4444,10 @@ def sample_delete_vod_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: @@ -4431,7 +4526,7 @@ def update_vod_config( 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 VOD config. Only update fields specified in the call method body. @@ -4493,8 +4588,10 @@ def sample_update_vod_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: @@ -4579,7 +4676,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. @@ -4590,8 +4687,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. @@ -4632,7 +4731,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. @@ -4643,8 +4742,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. @@ -4685,7 +4786,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. @@ -4701,8 +4802,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 """ @@ -4739,7 +4842,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. @@ -4754,8 +4857,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 """ diff --git a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/pagers.py b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/pagers.py index 63ed6d96a52d..8f4dd6533e21 100644 --- a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/pagers.py +++ b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/pagers.py @@ -75,7 +75,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -89,8 +89,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = video_stitcher_service.ListCdnKeysRequest(request) @@ -149,7 +151,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. @@ -163,8 +165,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 = video_stitcher_service.ListCdnKeysRequest(request) @@ -227,7 +231,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -241,8 +245,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = video_stitcher_service.ListVodStitchDetailsRequest(request) @@ -303,7 +309,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. @@ -317,8 +323,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 = video_stitcher_service.ListVodStitchDetailsRequest(request) @@ -383,7 +391,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -397,8 +405,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = video_stitcher_service.ListVodAdTagDetailsRequest(request) @@ -459,7 +469,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. @@ -473,8 +483,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 = video_stitcher_service.ListVodAdTagDetailsRequest(request) @@ -539,7 +551,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -553,8 +565,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = video_stitcher_service.ListLiveAdTagDetailsRequest(request) @@ -615,7 +629,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. @@ -629,8 +643,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 = video_stitcher_service.ListLiveAdTagDetailsRequest(request) @@ -695,7 +711,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -709,8 +725,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = video_stitcher_service.ListSlatesRequest(request) @@ -769,7 +787,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. @@ -783,8 +801,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 = video_stitcher_service.ListSlatesRequest(request) @@ -847,7 +867,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -861,8 +881,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = video_stitcher_service.ListLiveConfigsRequest(request) @@ -923,7 +945,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. @@ -937,8 +959,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 = video_stitcher_service.ListLiveConfigsRequest(request) @@ -1003,7 +1027,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1017,8 +1041,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = video_stitcher_service.ListVodConfigsRequest(request) @@ -1077,7 +1103,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. @@ -1091,8 +1117,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 = video_stitcher_service.ListVodConfigsRequest(request) diff --git a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc.py b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc.py index a635ec756d63..1f8d50e7908b 100644 --- a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc.py +++ b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_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.cloud.video.stitcher_v1.types import ( ad_tag_details, @@ -36,6 +42,81 @@ from .base import DEFAULT_CLIENT_INFO, VideoStitcherServiceTransport +try: + from google.api_core import client_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.video.stitcher.v1.VideoStitcherService", + "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.video.stitcher.v1.VideoStitcherService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VideoStitcherServiceGrpcTransport(VideoStitcherServiceTransport): """gRPC backend transport for VideoStitcherService. @@ -194,7 +275,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,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 @@ -284,7 +372,7 @@ def create_cdn_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_cdn_key" not in self._stubs: - self._stubs["create_cdn_key"] = self.grpc_channel.unary_unary( + self._stubs["create_cdn_key"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/CreateCdnKey", request_serializer=video_stitcher_service.CreateCdnKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -314,7 +402,7 @@ def list_cdn_keys( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_cdn_keys" not in self._stubs: - self._stubs["list_cdn_keys"] = self.grpc_channel.unary_unary( + self._stubs["list_cdn_keys"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/ListCdnKeys", request_serializer=video_stitcher_service.ListCdnKeysRequest.serialize, response_deserializer=video_stitcher_service.ListCdnKeysResponse.deserialize, @@ -340,7 +428,7 @@ def get_cdn_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_cdn_key" not in self._stubs: - self._stubs["get_cdn_key"] = self.grpc_channel.unary_unary( + self._stubs["get_cdn_key"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/GetCdnKey", request_serializer=video_stitcher_service.GetCdnKeyRequest.serialize, response_deserializer=cdn_keys.CdnKey.deserialize, @@ -368,7 +456,7 @@ def delete_cdn_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_cdn_key" not in self._stubs: - self._stubs["delete_cdn_key"] = self.grpc_channel.unary_unary( + self._stubs["delete_cdn_key"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/DeleteCdnKey", request_serializer=video_stitcher_service.DeleteCdnKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -397,7 +485,7 @@ def update_cdn_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_cdn_key" not in self._stubs: - self._stubs["update_cdn_key"] = self.grpc_channel.unary_unary( + self._stubs["update_cdn_key"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/UpdateCdnKey", request_serializer=video_stitcher_service.UpdateCdnKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -427,7 +515,7 @@ def create_vod_session( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_vod_session" not in self._stubs: - self._stubs["create_vod_session"] = self.grpc_channel.unary_unary( + self._stubs["create_vod_session"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/CreateVodSession", request_serializer=video_stitcher_service.CreateVodSessionRequest.serialize, response_deserializer=sessions.VodSession.deserialize, @@ -454,7 +542,7 @@ def get_vod_session( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_vod_session" not in self._stubs: - self._stubs["get_vod_session"] = self.grpc_channel.unary_unary( + self._stubs["get_vod_session"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/GetVodSession", request_serializer=video_stitcher_service.GetVodSessionRequest.serialize, response_deserializer=sessions.VodSession.deserialize, @@ -484,7 +572,7 @@ def list_vod_stitch_details( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_vod_stitch_details" not in self._stubs: - self._stubs["list_vod_stitch_details"] = self.grpc_channel.unary_unary( + self._stubs["list_vod_stitch_details"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/ListVodStitchDetails", request_serializer=video_stitcher_service.ListVodStitchDetailsRequest.serialize, response_deserializer=video_stitcher_service.ListVodStitchDetailsResponse.deserialize, @@ -514,7 +602,7 @@ def get_vod_stitch_detail( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_vod_stitch_detail" not in self._stubs: - self._stubs["get_vod_stitch_detail"] = self.grpc_channel.unary_unary( + self._stubs["get_vod_stitch_detail"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/GetVodStitchDetail", request_serializer=video_stitcher_service.GetVodStitchDetailRequest.serialize, response_deserializer=stitch_details.VodStitchDetail.deserialize, @@ -544,7 +632,7 @@ def list_vod_ad_tag_details( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_vod_ad_tag_details" not in self._stubs: - self._stubs["list_vod_ad_tag_details"] = self.grpc_channel.unary_unary( + self._stubs["list_vod_ad_tag_details"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/ListVodAdTagDetails", request_serializer=video_stitcher_service.ListVodAdTagDetailsRequest.serialize, response_deserializer=video_stitcher_service.ListVodAdTagDetailsResponse.deserialize, @@ -573,7 +661,7 @@ def get_vod_ad_tag_detail( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_vod_ad_tag_detail" not in self._stubs: - self._stubs["get_vod_ad_tag_detail"] = self.grpc_channel.unary_unary( + self._stubs["get_vod_ad_tag_detail"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/GetVodAdTagDetail", request_serializer=video_stitcher_service.GetVodAdTagDetailRequest.serialize, response_deserializer=ad_tag_details.VodAdTagDetail.deserialize, @@ -603,7 +691,7 @@ def list_live_ad_tag_details( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_live_ad_tag_details" not in self._stubs: - self._stubs["list_live_ad_tag_details"] = self.grpc_channel.unary_unary( + self._stubs["list_live_ad_tag_details"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/ListLiveAdTagDetails", request_serializer=video_stitcher_service.ListLiveAdTagDetailsRequest.serialize, response_deserializer=video_stitcher_service.ListLiveAdTagDetailsResponse.deserialize, @@ -633,7 +721,7 @@ def get_live_ad_tag_detail( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_live_ad_tag_detail" not in self._stubs: - self._stubs["get_live_ad_tag_detail"] = self.grpc_channel.unary_unary( + self._stubs["get_live_ad_tag_detail"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/GetLiveAdTagDetail", request_serializer=video_stitcher_service.GetLiveAdTagDetailRequest.serialize, response_deserializer=ad_tag_details.LiveAdTagDetail.deserialize, @@ -661,7 +749,7 @@ def create_slate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_slate" not in self._stubs: - self._stubs["create_slate"] = self.grpc_channel.unary_unary( + self._stubs["create_slate"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/CreateSlate", request_serializer=video_stitcher_service.CreateSlateRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -691,7 +779,7 @@ def list_slates( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_slates" not in self._stubs: - self._stubs["list_slates"] = self.grpc_channel.unary_unary( + self._stubs["list_slates"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/ListSlates", request_serializer=video_stitcher_service.ListSlatesRequest.serialize, response_deserializer=video_stitcher_service.ListSlatesResponse.deserialize, @@ -717,7 +805,7 @@ def get_slate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_slate" not in self._stubs: - self._stubs["get_slate"] = self.grpc_channel.unary_unary( + self._stubs["get_slate"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/GetSlate", request_serializer=video_stitcher_service.GetSlateRequest.serialize, response_deserializer=slates.Slate.deserialize, @@ -745,7 +833,7 @@ def update_slate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_slate" not in self._stubs: - self._stubs["update_slate"] = self.grpc_channel.unary_unary( + self._stubs["update_slate"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/UpdateSlate", request_serializer=video_stitcher_service.UpdateSlateRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -773,7 +861,7 @@ def delete_slate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_slate" not in self._stubs: - self._stubs["delete_slate"] = self.grpc_channel.unary_unary( + self._stubs["delete_slate"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/DeleteSlate", request_serializer=video_stitcher_service.DeleteSlateRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -801,7 +889,7 @@ def create_live_session( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_live_session" not in self._stubs: - self._stubs["create_live_session"] = self.grpc_channel.unary_unary( + self._stubs["create_live_session"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/CreateLiveSession", request_serializer=video_stitcher_service.CreateLiveSessionRequest.serialize, response_deserializer=sessions.LiveSession.deserialize, @@ -827,7 +915,7 @@ def get_live_session( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_live_session" not in self._stubs: - self._stubs["get_live_session"] = self.grpc_channel.unary_unary( + self._stubs["get_live_session"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/GetLiveSession", request_serializer=video_stitcher_service.GetLiveSessionRequest.serialize, response_deserializer=sessions.LiveSession.deserialize, @@ -856,7 +944,7 @@ def create_live_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_live_config" not in self._stubs: - self._stubs["create_live_config"] = self.grpc_channel.unary_unary( + self._stubs["create_live_config"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/CreateLiveConfig", request_serializer=video_stitcher_service.CreateLiveConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -886,7 +974,7 @@ def list_live_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_live_configs" not in self._stubs: - self._stubs["list_live_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_live_configs"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/ListLiveConfigs", request_serializer=video_stitcher_service.ListLiveConfigsRequest.serialize, response_deserializer=video_stitcher_service.ListLiveConfigsResponse.deserialize, @@ -915,7 +1003,7 @@ def get_live_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_live_config" not in self._stubs: - self._stubs["get_live_config"] = self.grpc_channel.unary_unary( + self._stubs["get_live_config"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/GetLiveConfig", request_serializer=video_stitcher_service.GetLiveConfigRequest.serialize, response_deserializer=live_configs.LiveConfig.deserialize, @@ -943,7 +1031,7 @@ def delete_live_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_live_config" not in self._stubs: - self._stubs["delete_live_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_live_config"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/DeleteLiveConfig", request_serializer=video_stitcher_service.DeleteLiveConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -972,7 +1060,7 @@ def update_live_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_live_config" not in self._stubs: - self._stubs["update_live_config"] = self.grpc_channel.unary_unary( + self._stubs["update_live_config"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/UpdateLiveConfig", request_serializer=video_stitcher_service.UpdateLiveConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1001,7 +1089,7 @@ def create_vod_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_vod_config" not in self._stubs: - self._stubs["create_vod_config"] = self.grpc_channel.unary_unary( + self._stubs["create_vod_config"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/CreateVodConfig", request_serializer=video_stitcher_service.CreateVodConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1031,7 +1119,7 @@ def list_vod_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_vod_configs" not in self._stubs: - self._stubs["list_vod_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_vod_configs"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/ListVodConfigs", request_serializer=video_stitcher_service.ListVodConfigsRequest.serialize, response_deserializer=video_stitcher_service.ListVodConfigsResponse.deserialize, @@ -1058,7 +1146,7 @@ def get_vod_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_vod_config" not in self._stubs: - self._stubs["get_vod_config"] = self.grpc_channel.unary_unary( + self._stubs["get_vod_config"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/GetVodConfig", request_serializer=video_stitcher_service.GetVodConfigRequest.serialize, response_deserializer=vod_configs.VodConfig.deserialize, @@ -1086,7 +1174,7 @@ def delete_vod_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_vod_config" not in self._stubs: - self._stubs["delete_vod_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_vod_config"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/DeleteVodConfig", request_serializer=video_stitcher_service.DeleteVodConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1115,7 +1203,7 @@ def update_vod_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_vod_config" not in self._stubs: - self._stubs["update_vod_config"] = self.grpc_channel.unary_unary( + self._stubs["update_vod_config"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/UpdateVodConfig", request_serializer=video_stitcher_service.UpdateVodConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1123,7 +1211,7 @@ def update_vod_config( return self._stubs["update_vod_config"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -1135,7 +1223,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, @@ -1152,7 +1240,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, @@ -1169,7 +1257,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, @@ -1188,7 +1276,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-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc_asyncio.py b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc_asyncio.py index 66cfca6a09dd..4ef796d8e388 100644 --- a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_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.video.stitcher_v1.types import ( ad_tag_details, @@ -40,6 +46,82 @@ from .base import DEFAULT_CLIENT_INFO, VideoStitcherServiceTransport from .grpc import VideoStitcherServiceGrpcTransport +try: + from google.api_core import client_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.video.stitcher.v1.VideoStitcherService", + "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.video.stitcher.v1.VideoStitcherService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VideoStitcherServiceGrpcAsyncIOTransport(VideoStitcherServiceTransport): """gRPC AsyncIO backend transport for VideoStitcherService. @@ -241,10 +323,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 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. @@ -295,7 +380,7 @@ def create_cdn_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_cdn_key" not in self._stubs: - self._stubs["create_cdn_key"] = self.grpc_channel.unary_unary( + self._stubs["create_cdn_key"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/CreateCdnKey", request_serializer=video_stitcher_service.CreateCdnKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -325,7 +410,7 @@ def list_cdn_keys( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_cdn_keys" not in self._stubs: - self._stubs["list_cdn_keys"] = self.grpc_channel.unary_unary( + self._stubs["list_cdn_keys"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/ListCdnKeys", request_serializer=video_stitcher_service.ListCdnKeysRequest.serialize, response_deserializer=video_stitcher_service.ListCdnKeysResponse.deserialize, @@ -353,7 +438,7 @@ def get_cdn_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_cdn_key" not in self._stubs: - self._stubs["get_cdn_key"] = self.grpc_channel.unary_unary( + self._stubs["get_cdn_key"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/GetCdnKey", request_serializer=video_stitcher_service.GetCdnKeyRequest.serialize, response_deserializer=cdn_keys.CdnKey.deserialize, @@ -382,7 +467,7 @@ def delete_cdn_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_cdn_key" not in self._stubs: - self._stubs["delete_cdn_key"] = self.grpc_channel.unary_unary( + self._stubs["delete_cdn_key"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/DeleteCdnKey", request_serializer=video_stitcher_service.DeleteCdnKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -412,7 +497,7 @@ def update_cdn_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_cdn_key" not in self._stubs: - self._stubs["update_cdn_key"] = self.grpc_channel.unary_unary( + self._stubs["update_cdn_key"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/UpdateCdnKey", request_serializer=video_stitcher_service.UpdateCdnKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -442,7 +527,7 @@ def create_vod_session( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_vod_session" not in self._stubs: - self._stubs["create_vod_session"] = self.grpc_channel.unary_unary( + self._stubs["create_vod_session"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/CreateVodSession", request_serializer=video_stitcher_service.CreateVodSessionRequest.serialize, response_deserializer=sessions.VodSession.deserialize, @@ -471,7 +556,7 @@ def get_vod_session( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_vod_session" not in self._stubs: - self._stubs["get_vod_session"] = self.grpc_channel.unary_unary( + self._stubs["get_vod_session"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/GetVodSession", request_serializer=video_stitcher_service.GetVodSessionRequest.serialize, response_deserializer=sessions.VodSession.deserialize, @@ -501,7 +586,7 @@ def list_vod_stitch_details( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_vod_stitch_details" not in self._stubs: - self._stubs["list_vod_stitch_details"] = self.grpc_channel.unary_unary( + self._stubs["list_vod_stitch_details"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/ListVodStitchDetails", request_serializer=video_stitcher_service.ListVodStitchDetailsRequest.serialize, response_deserializer=video_stitcher_service.ListVodStitchDetailsResponse.deserialize, @@ -531,7 +616,7 @@ def get_vod_stitch_detail( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_vod_stitch_detail" not in self._stubs: - self._stubs["get_vod_stitch_detail"] = self.grpc_channel.unary_unary( + self._stubs["get_vod_stitch_detail"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/GetVodStitchDetail", request_serializer=video_stitcher_service.GetVodStitchDetailRequest.serialize, response_deserializer=stitch_details.VodStitchDetail.deserialize, @@ -561,7 +646,7 @@ def list_vod_ad_tag_details( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_vod_ad_tag_details" not in self._stubs: - self._stubs["list_vod_ad_tag_details"] = self.grpc_channel.unary_unary( + self._stubs["list_vod_ad_tag_details"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/ListVodAdTagDetails", request_serializer=video_stitcher_service.ListVodAdTagDetailsRequest.serialize, response_deserializer=video_stitcher_service.ListVodAdTagDetailsResponse.deserialize, @@ -591,7 +676,7 @@ def get_vod_ad_tag_detail( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_vod_ad_tag_detail" not in self._stubs: - self._stubs["get_vod_ad_tag_detail"] = self.grpc_channel.unary_unary( + self._stubs["get_vod_ad_tag_detail"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/GetVodAdTagDetail", request_serializer=video_stitcher_service.GetVodAdTagDetailRequest.serialize, response_deserializer=ad_tag_details.VodAdTagDetail.deserialize, @@ -621,7 +706,7 @@ def list_live_ad_tag_details( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_live_ad_tag_details" not in self._stubs: - self._stubs["list_live_ad_tag_details"] = self.grpc_channel.unary_unary( + self._stubs["list_live_ad_tag_details"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/ListLiveAdTagDetails", request_serializer=video_stitcher_service.ListLiveAdTagDetailsRequest.serialize, response_deserializer=video_stitcher_service.ListLiveAdTagDetailsResponse.deserialize, @@ -651,7 +736,7 @@ def get_live_ad_tag_detail( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_live_ad_tag_detail" not in self._stubs: - self._stubs["get_live_ad_tag_detail"] = self.grpc_channel.unary_unary( + self._stubs["get_live_ad_tag_detail"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/GetLiveAdTagDetail", request_serializer=video_stitcher_service.GetLiveAdTagDetailRequest.serialize, response_deserializer=ad_tag_details.LiveAdTagDetail.deserialize, @@ -679,7 +764,7 @@ def create_slate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_slate" not in self._stubs: - self._stubs["create_slate"] = self.grpc_channel.unary_unary( + self._stubs["create_slate"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/CreateSlate", request_serializer=video_stitcher_service.CreateSlateRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -709,7 +794,7 @@ def list_slates( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_slates" not in self._stubs: - self._stubs["list_slates"] = self.grpc_channel.unary_unary( + self._stubs["list_slates"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/ListSlates", request_serializer=video_stitcher_service.ListSlatesRequest.serialize, response_deserializer=video_stitcher_service.ListSlatesResponse.deserialize, @@ -735,7 +820,7 @@ def get_slate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_slate" not in self._stubs: - self._stubs["get_slate"] = self.grpc_channel.unary_unary( + self._stubs["get_slate"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/GetSlate", request_serializer=video_stitcher_service.GetSlateRequest.serialize, response_deserializer=slates.Slate.deserialize, @@ -763,7 +848,7 @@ def update_slate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_slate" not in self._stubs: - self._stubs["update_slate"] = self.grpc_channel.unary_unary( + self._stubs["update_slate"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/UpdateSlate", request_serializer=video_stitcher_service.UpdateSlateRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -791,7 +876,7 @@ def delete_slate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_slate" not in self._stubs: - self._stubs["delete_slate"] = self.grpc_channel.unary_unary( + self._stubs["delete_slate"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/DeleteSlate", request_serializer=video_stitcher_service.DeleteSlateRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -820,7 +905,7 @@ def create_live_session( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_live_session" not in self._stubs: - self._stubs["create_live_session"] = self.grpc_channel.unary_unary( + self._stubs["create_live_session"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/CreateLiveSession", request_serializer=video_stitcher_service.CreateLiveSessionRequest.serialize, response_deserializer=sessions.LiveSession.deserialize, @@ -848,7 +933,7 @@ def get_live_session( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_live_session" not in self._stubs: - self._stubs["get_live_session"] = self.grpc_channel.unary_unary( + self._stubs["get_live_session"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/GetLiveSession", request_serializer=video_stitcher_service.GetLiveSessionRequest.serialize, response_deserializer=sessions.LiveSession.deserialize, @@ -878,7 +963,7 @@ def create_live_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_live_config" not in self._stubs: - self._stubs["create_live_config"] = self.grpc_channel.unary_unary( + self._stubs["create_live_config"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/CreateLiveConfig", request_serializer=video_stitcher_service.CreateLiveConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -908,7 +993,7 @@ def list_live_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_live_configs" not in self._stubs: - self._stubs["list_live_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_live_configs"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/ListLiveConfigs", request_serializer=video_stitcher_service.ListLiveConfigsRequest.serialize, response_deserializer=video_stitcher_service.ListLiveConfigsResponse.deserialize, @@ -938,7 +1023,7 @@ def get_live_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_live_config" not in self._stubs: - self._stubs["get_live_config"] = self.grpc_channel.unary_unary( + self._stubs["get_live_config"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/GetLiveConfig", request_serializer=video_stitcher_service.GetLiveConfigRequest.serialize, response_deserializer=live_configs.LiveConfig.deserialize, @@ -967,7 +1052,7 @@ def delete_live_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_live_config" not in self._stubs: - self._stubs["delete_live_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_live_config"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/DeleteLiveConfig", request_serializer=video_stitcher_service.DeleteLiveConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -997,7 +1082,7 @@ def update_live_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_live_config" not in self._stubs: - self._stubs["update_live_config"] = self.grpc_channel.unary_unary( + self._stubs["update_live_config"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/UpdateLiveConfig", request_serializer=video_stitcher_service.UpdateLiveConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1027,7 +1112,7 @@ def create_vod_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_vod_config" not in self._stubs: - self._stubs["create_vod_config"] = self.grpc_channel.unary_unary( + self._stubs["create_vod_config"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/CreateVodConfig", request_serializer=video_stitcher_service.CreateVodConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1057,7 +1142,7 @@ def list_vod_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_vod_configs" not in self._stubs: - self._stubs["list_vod_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_vod_configs"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/ListVodConfigs", request_serializer=video_stitcher_service.ListVodConfigsRequest.serialize, response_deserializer=video_stitcher_service.ListVodConfigsResponse.deserialize, @@ -1086,7 +1171,7 @@ def get_vod_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_vod_config" not in self._stubs: - self._stubs["get_vod_config"] = self.grpc_channel.unary_unary( + self._stubs["get_vod_config"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/GetVodConfig", request_serializer=video_stitcher_service.GetVodConfigRequest.serialize, response_deserializer=vod_configs.VodConfig.deserialize, @@ -1115,7 +1200,7 @@ def delete_vod_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_vod_config" not in self._stubs: - self._stubs["delete_vod_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_vod_config"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/DeleteVodConfig", request_serializer=video_stitcher_service.DeleteVodConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1145,7 +1230,7 @@ def update_vod_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_vod_config" not in self._stubs: - self._stubs["update_vod_config"] = self.grpc_channel.unary_unary( + self._stubs["update_vod_config"] = self._logged_channel.unary_unary( "/google.cloud.video.stitcher.v1.VideoStitcherService/UpdateVodConfig", request_serializer=video_stitcher_service.UpdateVodConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1333,7 +1418,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: @@ -1349,7 +1434,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, @@ -1366,7 +1451,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, @@ -1383,7 +1468,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, @@ -1402,7 +1487,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-video-stitcher/samples/generated_samples/snippet_metadata_google.cloud.video.stitcher.v1.json b/packages/google-cloud-video-stitcher/samples/generated_samples/snippet_metadata_google.cloud.video.stitcher.v1.json index 222f0b54279a..2e9dbfeedb7e 100644 --- a/packages/google-cloud-video-stitcher/samples/generated_samples/snippet_metadata_google.cloud.video.stitcher.v1.json +++ b/packages/google-cloud-video-stitcher/samples/generated_samples/snippet_metadata_google.cloud.video.stitcher.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-video-stitcher", - "version": "0.7.14" + "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", @@ -405,7 +405,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.LiveSession", @@ -489,7 +489,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.LiveSession", @@ -578,7 +578,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -666,7 +666,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -755,7 +755,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -843,7 +843,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -928,7 +928,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.VodSession", @@ -1012,7 +1012,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.VodSession", @@ -1093,7 +1093,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1173,7 +1173,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1254,7 +1254,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1334,7 +1334,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1415,7 +1415,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1495,7 +1495,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1576,7 +1576,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1656,7 +1656,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1737,7 +1737,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.CdnKey", @@ -1817,7 +1817,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.CdnKey", @@ -1898,7 +1898,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.LiveAdTagDetail", @@ -1978,7 +1978,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.LiveAdTagDetail", @@ -2059,7 +2059,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.LiveConfig", @@ -2139,7 +2139,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.LiveConfig", @@ -2220,7 +2220,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.LiveSession", @@ -2300,7 +2300,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.LiveSession", @@ -2381,7 +2381,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.Slate", @@ -2461,7 +2461,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.Slate", @@ -2542,7 +2542,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.VodAdTagDetail", @@ -2622,7 +2622,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.VodAdTagDetail", @@ -2703,7 +2703,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.VodConfig", @@ -2783,7 +2783,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.VodConfig", @@ -2864,7 +2864,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.VodSession", @@ -2944,7 +2944,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.VodSession", @@ -3025,7 +3025,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.VodStitchDetail", @@ -3105,7 +3105,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.VodStitchDetail", @@ -3186,7 +3186,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListCdnKeysAsyncPager", @@ -3266,7 +3266,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListCdnKeysPager", @@ -3347,7 +3347,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveAdTagDetailsAsyncPager", @@ -3427,7 +3427,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveAdTagDetailsPager", @@ -3508,7 +3508,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveConfigsAsyncPager", @@ -3588,7 +3588,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveConfigsPager", @@ -3669,7 +3669,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListSlatesAsyncPager", @@ -3749,7 +3749,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListSlatesPager", @@ -3830,7 +3830,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodAdTagDetailsAsyncPager", @@ -3910,7 +3910,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodAdTagDetailsPager", @@ -3991,7 +3991,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodConfigsAsyncPager", @@ -4071,7 +4071,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodConfigsPager", @@ -4152,7 +4152,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodStitchDetailsAsyncPager", @@ -4232,7 +4232,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodStitchDetailsPager", @@ -4317,7 +4317,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4401,7 +4401,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4486,7 +4486,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4570,7 +4570,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4655,7 +4655,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4739,7 +4739,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4824,7 +4824,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4908,7 +4908,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-video-transcoder/google/cloud/video/transcoder/gapic_version.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder/gapic_version.py index 0b9427f4e8a5..558c8aab67c5 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder/gapic_version.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.13.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/gapic_version.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/gapic_version.py index 0b9427f4e8a5..558c8aab67c5 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/gapic_version.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.13.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/async_client.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/async_client.py index 25080697d07f..7d119a8b052a 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/async_client.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_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, @@ -52,6 +53,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TranscoderServiceTransport from .transports.grpc_asyncio import TranscoderServiceGrpcAsyncIOTransport +try: + from google.api_core import client_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 TranscoderServiceAsyncClient: """Using the Transcoder API, you can queue asynchronous jobs for @@ -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.video.transcoder_v1.TranscoderServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "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.video.transcoder.v1.TranscoderService", + "credentialsType": None, + }, + ) + async def create_job( self, request: Optional[Union[services.CreateJobRequest, dict]] = None, @@ -280,7 +312,7 @@ async def create_job( job: Optional[resources.Job] = None, retry: OptionalRetry = 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.Job: r"""Creates a job in the specified region. @@ -334,8 +366,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.video.transcoder_v1.types.Job: @@ -396,7 +430,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"""Lists jobs in the specified region. @@ -442,8 +476,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.video.transcoder_v1.services.transcoder_service.pagers.ListJobsAsyncPager: @@ -517,7 +553,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]]] = (), ) -> resources.Job: r"""Returns the job data. @@ -560,8 +596,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.video.transcoder_v1.types.Job: @@ -618,7 +656,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]]] = (), ) -> None: r"""Deletes a job. @@ -658,8 +696,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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -713,7 +753,7 @@ async def create_job_template( job_template_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.JobTemplate: r"""Creates a job template in the specified region. @@ -778,8 +818,10 @@ async def sample_create_job_template(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.transcoder_v1.types.JobTemplate: @@ -842,7 +884,7 @@ async def list_job_templates( 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.ListJobTemplatesAsyncPager: r"""Lists job templates in the specified region. @@ -888,8 +930,10 @@ async def sample_list_job_templates(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.transcoder_v1.services.transcoder_service.pagers.ListJobTemplatesAsyncPager: @@ -963,7 +1007,7 @@ async def get_job_template( name: Optional[str] = None, retry: OptionalRetry = 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.JobTemplate: r"""Returns the job template data. @@ -1008,8 +1052,10 @@ async def sample_get_job_template(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.transcoder_v1.types.JobTemplate: @@ -1068,7 +1114,7 @@ async def delete_job_template( name: Optional[str] = None, retry: OptionalRetry = 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 job template. @@ -1109,8 +1155,10 @@ async def sample_delete_job_template(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/client.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/client.py index da7eec12448a..4771712408cc 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/client.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_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.rpc import status_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( @@ -680,6 +694,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.video.transcoder_v1.TranscoderServiceClient`.", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "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.video.transcoder.v1.TranscoderService", + "credentialsType": None, + }, + ) + def create_job( self, request: Optional[Union[services.CreateJobRequest, dict]] = None, @@ -688,7 +725,7 @@ def create_job( job: Optional[resources.Job] = None, retry: OptionalRetry = 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.Job: r"""Creates a job in the specified region. @@ -742,8 +779,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.video.transcoder_v1.types.Job: @@ -801,7 +840,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"""Lists jobs in the specified region. @@ -847,8 +886,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.video.transcoder_v1.services.transcoder_service.pagers.ListJobsPager: @@ -919,7 +960,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]]] = (), ) -> resources.Job: r"""Returns the job data. @@ -962,8 +1003,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.video.transcoder_v1.types.Job: @@ -1019,7 +1062,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]]] = (), ) -> None: r"""Deletes a job. @@ -1059,8 +1102,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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1111,7 +1156,7 @@ def create_job_template( job_template_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.JobTemplate: r"""Creates a job template in the specified region. @@ -1176,8 +1221,10 @@ def sample_create_job_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.cloud.video.transcoder_v1.types.JobTemplate: @@ -1237,7 +1284,7 @@ def list_job_templates( 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.ListJobTemplatesPager: r"""Lists job templates in the specified region. @@ -1283,8 +1330,10 @@ def sample_list_job_templates(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.video.transcoder_v1.services.transcoder_service.pagers.ListJobTemplatesPager: @@ -1355,7 +1404,7 @@ def get_job_template( name: Optional[str] = None, retry: OptionalRetry = 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.JobTemplate: r"""Returns the job template data. @@ -1400,8 +1449,10 @@ def sample_get_job_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.cloud.video.transcoder_v1.types.JobTemplate: @@ -1457,7 +1508,7 @@ def delete_job_template( name: Optional[str] = None, retry: OptionalRetry = 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 job template. @@ -1498,8 +1549,10 @@ def sample_delete_job_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have diff --git a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/pagers.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/pagers.py index 478cc3688ead..8ceda6c0434c 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/pagers.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_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 = services.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 = services.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 = services.ListJobTemplatesRequest(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 = services.ListJobTemplatesRequest(request) diff --git a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/transports/grpc.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/transports/grpc.py index dbeb8d16d5cd..d5f518b44943 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/transports/grpc.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_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.cloud.video.transcoder_v1.types import resources, services from .base import DEFAULT_CLIENT_INFO, TranscoderServiceTransport +try: + from google.api_core import client_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.video.transcoder.v1.TranscoderService", + "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.video.transcoder.v1.TranscoderService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TranscoderServiceGrpcTransport(TranscoderServiceTransport): """gRPC backend transport for TranscoderService. @@ -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 @@ -258,7 +344,7 @@ def create_job(self) -> Callable[[services.CreateJobRequest], resources.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.video.transcoder.v1.TranscoderService/CreateJob", request_serializer=services.CreateJobRequest.serialize, response_deserializer=resources.Job.deserialize, @@ -284,7 +370,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.video.transcoder.v1.TranscoderService/ListJobs", request_serializer=services.ListJobsRequest.serialize, response_deserializer=services.ListJobsResponse.deserialize, @@ -308,7 +394,7 @@ def get_job(self) -> Callable[[services.GetJobRequest], resources.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.video.transcoder.v1.TranscoderService/GetJob", request_serializer=services.GetJobRequest.serialize, response_deserializer=resources.Job.deserialize, @@ -332,7 +418,7 @@ def delete_job(self) -> Callable[[services.DeleteJobRequest], empty_pb2.Empty]: # 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.video.transcoder.v1.TranscoderService/DeleteJob", request_serializer=services.DeleteJobRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -358,7 +444,7 @@ def create_job_template( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_job_template" not in self._stubs: - self._stubs["create_job_template"] = self.grpc_channel.unary_unary( + self._stubs["create_job_template"] = self._logged_channel.unary_unary( "/google.cloud.video.transcoder.v1.TranscoderService/CreateJobTemplate", request_serializer=services.CreateJobTemplateRequest.serialize, response_deserializer=resources.JobTemplate.deserialize, @@ -386,7 +472,7 @@ def list_job_templates( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_job_templates" not in self._stubs: - self._stubs["list_job_templates"] = self.grpc_channel.unary_unary( + self._stubs["list_job_templates"] = self._logged_channel.unary_unary( "/google.cloud.video.transcoder.v1.TranscoderService/ListJobTemplates", request_serializer=services.ListJobTemplatesRequest.serialize, response_deserializer=services.ListJobTemplatesResponse.deserialize, @@ -412,7 +498,7 @@ def get_job_template( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_job_template" not in self._stubs: - self._stubs["get_job_template"] = self.grpc_channel.unary_unary( + self._stubs["get_job_template"] = self._logged_channel.unary_unary( "/google.cloud.video.transcoder.v1.TranscoderService/GetJobTemplate", request_serializer=services.GetJobTemplateRequest.serialize, response_deserializer=resources.JobTemplate.deserialize, @@ -438,7 +524,7 @@ def delete_job_template( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_job_template" not in self._stubs: - self._stubs["delete_job_template"] = self.grpc_channel.unary_unary( + self._stubs["delete_job_template"] = self._logged_channel.unary_unary( "/google.cloud.video.transcoder.v1.TranscoderService/DeleteJobTemplate", request_serializer=services.DeleteJobTemplateRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -446,7 +532,7 @@ def delete_job_template( return self._stubs["delete_job_template"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/transports/grpc_asyncio.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/transports/grpc_asyncio.py index 5e70c8789adb..f65ac2d65883 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_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.cloud.video.transcoder_v1.types import resources, services from .base import DEFAULT_CLIENT_INFO, TranscoderServiceTransport from .grpc import TranscoderServiceGrpcTransport +try: + from google.api_core import client_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.video.transcoder.v1.TranscoderService", + "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.video.transcoder.v1.TranscoderService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TranscoderServiceGrpcAsyncIOTransport(TranscoderServiceTransport): """gRPC AsyncIO backend transport for TranscoderService. @@ -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 @@ -268,7 +353,7 @@ def create_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.video.transcoder.v1.TranscoderService/CreateJob", request_serializer=services.CreateJobRequest.serialize, response_deserializer=resources.Job.deserialize, @@ -294,7 +379,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.video.transcoder.v1.TranscoderService/ListJobs", request_serializer=services.ListJobsRequest.serialize, response_deserializer=services.ListJobsResponse.deserialize, @@ -318,7 +403,7 @@ def get_job(self) -> Callable[[services.GetJobRequest], Awaitable[resources.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.video.transcoder.v1.TranscoderService/GetJob", request_serializer=services.GetJobRequest.serialize, response_deserializer=resources.Job.deserialize, @@ -344,7 +429,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.video.transcoder.v1.TranscoderService/DeleteJob", request_serializer=services.DeleteJobRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -372,7 +457,7 @@ def create_job_template( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_job_template" not in self._stubs: - self._stubs["create_job_template"] = self.grpc_channel.unary_unary( + self._stubs["create_job_template"] = self._logged_channel.unary_unary( "/google.cloud.video.transcoder.v1.TranscoderService/CreateJobTemplate", request_serializer=services.CreateJobTemplateRequest.serialize, response_deserializer=resources.JobTemplate.deserialize, @@ -400,7 +485,7 @@ def list_job_templates( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_job_templates" not in self._stubs: - self._stubs["list_job_templates"] = self.grpc_channel.unary_unary( + self._stubs["list_job_templates"] = self._logged_channel.unary_unary( "/google.cloud.video.transcoder.v1.TranscoderService/ListJobTemplates", request_serializer=services.ListJobTemplatesRequest.serialize, response_deserializer=services.ListJobTemplatesResponse.deserialize, @@ -426,7 +511,7 @@ def get_job_template( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_job_template" not in self._stubs: - self._stubs["get_job_template"] = self.grpc_channel.unary_unary( + self._stubs["get_job_template"] = self._logged_channel.unary_unary( "/google.cloud.video.transcoder.v1.TranscoderService/GetJobTemplate", request_serializer=services.GetJobTemplateRequest.serialize, response_deserializer=resources.JobTemplate.deserialize, @@ -452,7 +537,7 @@ def delete_job_template( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_job_template" not in self._stubs: - self._stubs["delete_job_template"] = self.grpc_channel.unary_unary( + self._stubs["delete_job_template"] = self._logged_channel.unary_unary( "/google.cloud.video.transcoder.v1.TranscoderService/DeleteJobTemplate", request_serializer=services.DeleteJobTemplateRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -510,7 +595,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-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/transports/rest.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/transports/rest.py index 1faac6128d09..0076df3c6aee 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/transports/rest.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_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, @@ -124,8 +132,10 @@ def post_list_job_templates(self, response): """ def pre_create_job( - self, request: services.CreateJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[services.CreateJobRequest, Sequence[Tuple[str, str]]]: + self, + request: services.CreateJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[services.CreateJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_job Override in a subclass to manipulate the request or metadata @@ -145,8 +155,10 @@ def post_create_job(self, response: resources.Job) -> resources.Job: def pre_create_job_template( self, request: services.CreateJobTemplateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[services.CreateJobTemplateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + services.CreateJobTemplateRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_job_template Override in a subclass to manipulate the request or metadata @@ -166,8 +178,10 @@ def post_create_job_template( return response def pre_delete_job( - self, request: services.DeleteJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[services.DeleteJobRequest, Sequence[Tuple[str, str]]]: + self, + request: services.DeleteJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[services.DeleteJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_job Override in a subclass to manipulate the request or metadata @@ -178,8 +192,10 @@ def pre_delete_job( def pre_delete_job_template( self, request: services.DeleteJobTemplateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[services.DeleteJobTemplateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + services.DeleteJobTemplateRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_job_template Override in a subclass to manipulate the request or metadata @@ -188,8 +204,10 @@ def pre_delete_job_template( return request, metadata def pre_get_job( - self, request: services.GetJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[services.GetJobRequest, Sequence[Tuple[str, str]]]: + self, + request: services.GetJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[services.GetJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_job Override in a subclass to manipulate the request or metadata @@ -209,8 +227,8 @@ def post_get_job(self, response: resources.Job) -> resources.Job: def pre_get_job_template( self, request: services.GetJobTemplateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[services.GetJobTemplateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[services.GetJobTemplateRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_job_template Override in a subclass to manipulate the request or metadata @@ -230,8 +248,10 @@ def post_get_job_template( return response def pre_list_jobs( - self, request: services.ListJobsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[services.ListJobsRequest, Sequence[Tuple[str, str]]]: + self, + request: services.ListJobsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[services.ListJobsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_jobs Override in a subclass to manipulate the request or metadata @@ -253,8 +273,10 @@ def post_list_jobs( def pre_list_job_templates( self, request: services.ListJobTemplatesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[services.ListJobTemplatesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + services.ListJobTemplatesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_job_templates Override in a subclass to manipulate the request or metadata @@ -401,7 +423,7 @@ 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.Job: r"""Call the create job method over HTTP. @@ -411,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: ~.resources.Job: @@ -422,6 +446,7 @@ def __call__( http_options = ( _BaseTranscoderServiceRestTransport._BaseCreateJob._get_http_options() ) + request, metadata = self._interceptor.pre_create_job(request, metadata) transcoded_request = _BaseTranscoderServiceRestTransport._BaseCreateJob._get_transcoded_request( http_options, request @@ -436,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.video.transcoder_v1.TranscoderServiceClient.CreateJob", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "CreateJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranscoderServiceRestTransport._CreateJob._get_response( self._host, @@ -457,7 +509,29 @@ def __call__( pb_resp = resources.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 = resources.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.video.transcoder_v1.TranscoderServiceClient.create_job", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "CreateJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateJobTemplate( @@ -496,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]]] = (), ) -> resources.JobTemplate: r"""Call the create job template method over HTTP. @@ -507,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: ~.resources.JobTemplate: @@ -518,6 +594,7 @@ def __call__( http_options = ( _BaseTranscoderServiceRestTransport._BaseCreateJobTemplate._get_http_options() ) + request, metadata = self._interceptor.pre_create_job_template( request, metadata ) @@ -534,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 = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.transcoder_v1.TranscoderServiceClient.CreateJobTemplate", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "CreateJobTemplate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranscoderServiceRestTransport._CreateJobTemplate._get_response( self._host, @@ -555,7 +659,29 @@ def __call__( pb_resp = resources.JobTemplate.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_job_template(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.JobTemplate.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.transcoder_v1.TranscoderServiceClient.create_job_template", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "CreateJobTemplate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteJob( @@ -592,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]]] = (), ): r"""Call the delete job method over HTTP. @@ -602,13 +728,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 = ( _BaseTranscoderServiceRestTransport._BaseDeleteJob._get_http_options() ) + request, metadata = self._interceptor.pre_delete_job(request, metadata) transcoded_request = _BaseTranscoderServiceRestTransport._BaseDeleteJob._get_transcoded_request( http_options, request @@ -619,6 +748,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.transcoder_v1.TranscoderServiceClient.DeleteJob", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "DeleteJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranscoderServiceRestTransport._DeleteJob._get_response( self._host, @@ -669,7 +825,7 @@ 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 job template method over HTTP. @@ -680,13 +836,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 = ( _BaseTranscoderServiceRestTransport._BaseDeleteJobTemplate._get_http_options() ) + request, metadata = self._interceptor.pre_delete_job_template( request, metadata ) @@ -699,6 +858,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.transcoder_v1.TranscoderServiceClient.DeleteJobTemplate", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "DeleteJobTemplate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranscoderServiceRestTransport._DeleteJobTemplate._get_response( self._host, @@ -748,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]]] = (), ) -> resources.Job: r"""Call the get job method over HTTP. @@ -758,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: ~.resources.Job: @@ -769,6 +957,7 @@ def __call__( http_options = ( _BaseTranscoderServiceRestTransport._BaseGetJob._get_http_options() ) + request, metadata = self._interceptor.pre_get_job(request, metadata) transcoded_request = ( _BaseTranscoderServiceRestTransport._BaseGetJob._get_transcoded_request( @@ -783,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.video.transcoder_v1.TranscoderServiceClient.GetJob", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "GetJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranscoderServiceRestTransport._GetJob._get_response( self._host, @@ -803,7 +1019,29 @@ def __call__( pb_resp = resources.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 = resources.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.video.transcoder_v1.TranscoderServiceClient.get_job", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "GetJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetJobTemplate( @@ -841,7 +1079,7 @@ 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.JobTemplate: r"""Call the get job template method over HTTP. @@ -852,8 +1090,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.JobTemplate: @@ -863,6 +1103,7 @@ def __call__( http_options = ( _BaseTranscoderServiceRestTransport._BaseGetJobTemplate._get_http_options() ) + request, metadata = self._interceptor.pre_get_job_template( request, metadata ) @@ -875,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.video.transcoder_v1.TranscoderServiceClient.GetJobTemplate", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "GetJobTemplate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranscoderServiceRestTransport._GetJobTemplate._get_response( self._host, @@ -895,7 +1163,29 @@ def __call__( pb_resp = resources.JobTemplate.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_job_template(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.JobTemplate.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.transcoder_v1.TranscoderServiceClient.get_job_template", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "GetJobTemplate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListJobs( @@ -932,7 +1222,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> services.ListJobsResponse: r"""Call the list jobs method over HTTP. @@ -944,8 +1234,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.services.ListJobsResponse: @@ -955,6 +1247,7 @@ def __call__( http_options = ( _BaseTranscoderServiceRestTransport._BaseListJobs._get_http_options() ) + request, metadata = self._interceptor.pre_list_jobs(request, metadata) transcoded_request = _BaseTranscoderServiceRestTransport._BaseListJobs._get_transcoded_request( http_options, request @@ -965,6 +1258,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.transcoder_v1.TranscoderServiceClient.ListJobs", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "ListJobs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranscoderServiceRestTransport._ListJobs._get_response( self._host, @@ -985,7 +1305,29 @@ def __call__( pb_resp = services.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 = services.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.video.transcoder_v1.TranscoderServiceClient.list_jobs", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "ListJobs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListJobTemplates( @@ -1023,7 +1365,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> services.ListJobTemplatesResponse: r"""Call the list job templates method over HTTP. @@ -1034,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: ~.services.ListJobTemplatesResponse: @@ -1047,6 +1391,7 @@ def __call__( http_options = ( _BaseTranscoderServiceRestTransport._BaseListJobTemplates._get_http_options() ) + request, metadata = self._interceptor.pre_list_job_templates( request, metadata ) @@ -1059,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 = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.transcoder_v1.TranscoderServiceClient.ListJobTemplates", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "ListJobTemplates", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranscoderServiceRestTransport._ListJobTemplates._get_response( self._host, @@ -1079,7 +1451,31 @@ def __call__( pb_resp = services.ListJobTemplatesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_job_templates(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = services.ListJobTemplatesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.transcoder_v1.TranscoderServiceClient.list_job_templates", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "ListJobTemplates", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-video-transcoder/samples/generated_samples/snippet_metadata_google.cloud.video.transcoder.v1.json b/packages/google-cloud-video-transcoder/samples/generated_samples/snippet_metadata_google.cloud.video.transcoder.v1.json index 093471c2ce59..5c4b962d53e7 100644 --- a/packages/google-cloud-video-transcoder/samples/generated_samples/snippet_metadata_google.cloud.video.transcoder.v1.json +++ b/packages/google-cloud-video-transcoder/samples/generated_samples/snippet_metadata_google.cloud.video.transcoder.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-video-transcoder", - "version": "1.13.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.cloud.video.transcoder_v1.types.JobTemplate", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.transcoder_v1.types.JobTemplate", @@ -228,7 +228,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.transcoder_v1.types.Job", @@ -312,7 +312,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.transcoder_v1.types.Job", @@ -393,7 +393,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_job_template" @@ -470,7 +470,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_job_template" @@ -548,7 +548,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_job" @@ -625,7 +625,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_job" @@ -703,7 +703,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.transcoder_v1.types.JobTemplate", @@ -783,7 +783,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.transcoder_v1.types.JobTemplate", @@ -864,7 +864,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.transcoder_v1.types.Job", @@ -944,7 +944,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.transcoder_v1.types.Job", @@ -1025,7 +1025,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.transcoder_v1.services.transcoder_service.pagers.ListJobTemplatesAsyncPager", @@ -1105,7 +1105,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.transcoder_v1.services.transcoder_service.pagers.ListJobTemplatesPager", @@ -1186,7 +1186,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.transcoder_v1.services.transcoder_service.pagers.ListJobsAsyncPager", @@ -1266,7 +1266,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.transcoder_v1.services.transcoder_service.pagers.ListJobsPager", diff --git a/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1/test_transcoder_service.py b/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1/test_transcoder_service.py index 959619ef021d..5022a6c73302 100644 --- a/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1/test_transcoder_service.py +++ b/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1/test_transcoder_service.py @@ -4309,6 +4309,7 @@ def test_create_job_rest_required_fields(request_type=services.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) @@ -4363,6 +4364,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) @@ -4501,6 +4503,7 @@ def test_list_jobs_rest_required_fields(request_type=services.ListJobsRequest): response_value._content = json_return_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) @@ -4556,6 +4559,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) @@ -4745,6 +4749,7 @@ def test_get_job_rest_required_fields(request_type=services.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) @@ -4790,6 +4795,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) @@ -4917,6 +4923,7 @@ def test_delete_job_rest_required_fields(request_type=services.DeleteJobRequest) response_value._content = json_return_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) @@ -4960,6 +4967,7 @@ def test_delete_job_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_job(**mock_args) @@ -5104,6 +5112,7 @@ def test_create_job_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.create_job_template(request) @@ -5166,6 +5175,7 @@ def test_create_job_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.create_job_template(**mock_args) @@ -5312,6 +5322,7 @@ def test_list_job_templates_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_job_templates(request) @@ -5367,6 +5378,7 @@ def test_list_job_templates_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_job_templates(**mock_args) @@ -5561,6 +5573,7 @@ def test_get_job_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.get_job_template(request) @@ -5608,6 +5621,7 @@ def test_get_job_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.get_job_template(**mock_args) @@ -5742,6 +5756,7 @@ def test_delete_job_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.delete_job_template(request) @@ -5787,6 +5802,7 @@ def test_delete_job_template_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_job_template(**mock_args) @@ -6366,6 +6382,7 @@ def test_create_job_rest_bad_request(request_type=services.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) @@ -6728,6 +6745,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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. @@ -6773,6 +6791,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 = resources.Job.to_json(resources.Job()) req.return_value.content = return_value @@ -6815,6 +6834,7 @@ def test_list_jobs_rest_bad_request(request_type=services.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) @@ -6851,6 +6871,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. @@ -6890,6 +6911,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 = services.ListJobsResponse.to_json(services.ListJobsResponse()) req.return_value.content = return_value @@ -6932,6 +6954,7 @@ def test_get_job_rest_bad_request(request_type=services.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) @@ -6975,6 +6998,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. @@ -7020,6 +7044,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 = resources.Job.to_json(resources.Job()) req.return_value.content = return_value @@ -7062,6 +7087,7 @@ def test_delete_job_rest_bad_request(request_type=services.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) @@ -7092,6 +7118,7 @@ def test_delete_job_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_job(request) # Establish that the response is the type that we expect. @@ -7126,6 +7153,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"} request = services.DeleteJobRequest() metadata = [ @@ -7166,6 +7194,7 @@ def test_create_job_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.create_job_template(request) @@ -7499,6 +7528,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_template(request) # Establish that the response is the type that we expect. @@ -7539,6 +7569,7 @@ def test_create_job_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 = resources.JobTemplate.to_json(resources.JobTemplate()) req.return_value.content = return_value @@ -7583,6 +7614,7 @@ def test_list_job_templates_rest_bad_request( response_value.status_code = 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_job_templates(request) @@ -7619,6 +7651,7 @@ def test_list_job_templates_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_job_templates(request) # Establish that the response is the type that we expect. @@ -7660,6 +7693,7 @@ def test_list_job_templates_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = services.ListJobTemplatesResponse.to_json( services.ListJobTemplatesResponse() ) @@ -7704,6 +7738,7 @@ def test_get_job_template_rest_bad_request(request_type=services.GetJobTemplateR response_value.status_code = 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_template(request) @@ -7739,6 +7774,7 @@ def test_get_job_template_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_template(request) # Establish that the response is the type that we expect. @@ -7777,6 +7813,7 @@ def test_get_job_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 = resources.JobTemplate.to_json(resources.JobTemplate()) req.return_value.content = return_value @@ -7821,6 +7858,7 @@ def test_delete_job_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.delete_job_template(request) @@ -7851,6 +7889,7 @@ def test_delete_job_template_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_job_template(request) # Establish that the response is the type that we expect. @@ -7887,6 +7926,7 @@ def test_delete_job_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"} request = services.DeleteJobTemplateRequest() metadata = [ diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence/gapic_version.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence/gapic_version.py index 2523dfbe9e23..558c8aab67c5 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence/gapic_version.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence/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-videointelligence/google/cloud/videointelligence_v1/gapic_version.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/gapic_version.py index 2523dfbe9e23..558c8aab67c5 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/gapic_version.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_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-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/async_client.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/async_client.py index 7c2aea04f1cb..7032b3ae25b8 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/async_client.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_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, VideoIntelligenceServiceTransport from .transports.grpc_asyncio import VideoIntelligenceServiceGrpcAsyncIOTransport +try: + from google.api_core import client_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 VideoIntelligenceServiceAsyncClient: """Service that implements the Video Intelligence API.""" @@ -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.videointelligence_v1.VideoIntelligenceServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.videointelligence.v1.VideoIntelligenceService", + "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.videointelligence.v1.VideoIntelligenceService", + "credentialsType": None, + }, + ) + async def annotate_video( self, request: Optional[Union[video_intelligence.AnnotateVideoRequest, dict]] = None, @@ -272,7 +304,7 @@ async def annotate_video( features: Optional[MutableSequence[video_intelligence.Feature]] = None, retry: OptionalRetry = gapic_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"""Performs asynchronous video annotation. Progress and results can be retrieved through the ``google.longrunning.Operations`` @@ -342,8 +374,10 @@ async def sample_annotate_video(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/client.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/client.py index 2b93cb9adc53..b3e545349294 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/client.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_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 @@ -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.videointelligence_v1.VideoIntelligenceServiceClient`.", + extra={ + "serviceName": "google.cloud.videointelligence.v1.VideoIntelligenceService", + "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.videointelligence.v1.VideoIntelligenceService", + "credentialsType": None, + }, + ) + def annotate_video( self, request: Optional[Union[video_intelligence.AnnotateVideoRequest, dict]] = None, @@ -640,7 +677,7 @@ def annotate_video( features: Optional[MutableSequence[video_intelligence.Feature]] = None, retry: OptionalRetry = gapic_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"""Performs asynchronous video annotation. Progress and results can be retrieved through the ``google.longrunning.Operations`` @@ -710,8 +747,10 @@ def sample_annotate_video(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/transports/grpc.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/transports/grpc.py index 7f9e8a54c275..a11e09feb562 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/transports/grpc.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_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.videointelligence_v1.types import video_intelligence from .base import DEFAULT_CLIENT_INFO, VideoIntelligenceServiceTransport +try: + from google.api_core import client_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.videointelligence.v1.VideoIntelligenceService", + "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.videointelligence.v1.VideoIntelligenceService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VideoIntelligenceServiceGrpcTransport(VideoIntelligenceServiceTransport): """gRPC backend transport for VideoIntelligenceService. @@ -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 @@ -245,7 +331,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 annotate_video( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "annotate_video" not in self._stubs: - self._stubs["annotate_video"] = self.grpc_channel.unary_unary( + self._stubs["annotate_video"] = self._logged_channel.unary_unary( "/google.cloud.videointelligence.v1.VideoIntelligenceService/AnnotateVideo", request_serializer=video_intelligence.AnnotateVideoRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -281,7 +369,7 @@ def annotate_video( return self._stubs["annotate_video"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/transports/grpc_asyncio.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/transports/grpc_asyncio.py index 95035f260faf..1d3be6b13e40 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_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.videointelligence_v1.types import video_intelligence from .base import DEFAULT_CLIENT_INFO, VideoIntelligenceServiceTransport from .grpc import VideoIntelligenceServiceGrpcTransport +try: + from google.api_core import client_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.videointelligence.v1.VideoIntelligenceService", + "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.videointelligence.v1.VideoIntelligenceService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VideoIntelligenceServiceGrpcAsyncIOTransport(VideoIntelligenceServiceTransport): """gRPC AsyncIO backend transport for VideoIntelligenceService. @@ -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 @@ -254,7 +339,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 annotate_video( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "annotate_video" not in self._stubs: - self._stubs["annotate_video"] = self.grpc_channel.unary_unary( + self._stubs["annotate_video"] = self._logged_channel.unary_unary( "/google.cloud.videointelligence.v1.VideoIntelligenceService/AnnotateVideo", request_serializer=video_intelligence.AnnotateVideoRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -318,7 +403,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-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/transports/rest.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/transports/rest.py index 05fd2cc8f0a1..e72c2ce9bf35 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/transports/rest.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_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, @@ -78,8 +86,10 @@ def post_annotate_video(self, response): def pre_annotate_video( self, request: video_intelligence.AnnotateVideoRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[video_intelligence.AnnotateVideoRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_intelligence.AnnotateVideoRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for annotate_video Override in a subclass to manipulate the request or metadata @@ -287,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]]] = (), ) -> operations_pb2.Operation: r"""Call the annotate video method over HTTP. @@ -297,8 +307,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -311,6 +323,7 @@ def __call__( http_options = ( _BaseVideoIntelligenceServiceRestTransport._BaseAnnotateVideo._get_http_options() ) + request, metadata = self._interceptor.pre_annotate_video(request, metadata) transcoded_request = _BaseVideoIntelligenceServiceRestTransport._BaseAnnotateVideo._get_transcoded_request( http_options, request @@ -325,6 +338,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.videointelligence_v1.VideoIntelligenceServiceClient.AnnotateVideo", + extra={ + "serviceName": "google.cloud.videointelligence.v1.VideoIntelligenceService", + "rpcName": "AnnotateVideo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VideoIntelligenceServiceRestTransport._AnnotateVideo._get_response( @@ -346,7 +386,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_annotate_video(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.videointelligence_v1.VideoIntelligenceServiceClient.annotate_video", + extra={ + "serviceName": "google.cloud.videointelligence.v1.VideoIntelligenceService", + "rpcName": "AnnotateVideo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/gapic_version.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/gapic_version.py index 2523dfbe9e23..558c8aab67c5 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/gapic_version.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/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-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/async_client.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/async_client.py index a34e91042374..b70c707a4cc3 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/async_client.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_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, VideoIntelligenceServiceTransport from .transports.grpc_asyncio import VideoIntelligenceServiceGrpcAsyncIOTransport +try: + from google.api_core import client_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 VideoIntelligenceServiceAsyncClient: """Service that implements Google Cloud Video Intelligence API.""" @@ -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.videointelligence_v1beta2.VideoIntelligenceServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.videointelligence.v1beta2.VideoIntelligenceService", + "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.videointelligence.v1beta2.VideoIntelligenceService", + "credentialsType": None, + }, + ) + async def annotate_video( self, request: Optional[Union[video_intelligence.AnnotateVideoRequest, dict]] = None, @@ -272,7 +304,7 @@ async def annotate_video( features: Optional[MutableSequence[video_intelligence.Feature]] = None, retry: OptionalRetry = gapic_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"""Performs asynchronous video annotation. Progress and results can be retrieved through the ``google.longrunning.Operations`` @@ -342,8 +374,10 @@ async def sample_annotate_video(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/client.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/client.py index 14b362c629ca..57dff58c1232 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/client.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_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 @@ -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.videointelligence_v1beta2.VideoIntelligenceServiceClient`.", + extra={ + "serviceName": "google.cloud.videointelligence.v1beta2.VideoIntelligenceService", + "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.videointelligence.v1beta2.VideoIntelligenceService", + "credentialsType": None, + }, + ) + def annotate_video( self, request: Optional[Union[video_intelligence.AnnotateVideoRequest, dict]] = None, @@ -640,7 +677,7 @@ def annotate_video( features: Optional[MutableSequence[video_intelligence.Feature]] = None, retry: OptionalRetry = gapic_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"""Performs asynchronous video annotation. Progress and results can be retrieved through the ``google.longrunning.Operations`` @@ -710,8 +747,10 @@ def sample_annotate_video(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/transports/grpc.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/transports/grpc.py index ab5f1eaa03ec..d391b5d6d1f3 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/transports/grpc.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_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.videointelligence_v1beta2.types import video_intelligence from .base import DEFAULT_CLIENT_INFO, VideoIntelligenceServiceTransport +try: + from google.api_core import client_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.videointelligence.v1beta2.VideoIntelligenceService", + "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.videointelligence.v1beta2.VideoIntelligenceService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VideoIntelligenceServiceGrpcTransport(VideoIntelligenceServiceTransport): """gRPC backend transport for VideoIntelligenceService. @@ -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 @@ -245,7 +331,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 annotate_video( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "annotate_video" not in self._stubs: - self._stubs["annotate_video"] = self.grpc_channel.unary_unary( + self._stubs["annotate_video"] = self._logged_channel.unary_unary( "/google.cloud.videointelligence.v1beta2.VideoIntelligenceService/AnnotateVideo", request_serializer=video_intelligence.AnnotateVideoRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -281,7 +369,7 @@ def annotate_video( return self._stubs["annotate_video"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/transports/grpc_asyncio.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/transports/grpc_asyncio.py index 6097f85f192b..cc9858d48c61 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_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.videointelligence_v1beta2.types import video_intelligence from .base import DEFAULT_CLIENT_INFO, VideoIntelligenceServiceTransport from .grpc import VideoIntelligenceServiceGrpcTransport +try: + from google.api_core import client_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.videointelligence.v1beta2.VideoIntelligenceService", + "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.videointelligence.v1beta2.VideoIntelligenceService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VideoIntelligenceServiceGrpcAsyncIOTransport(VideoIntelligenceServiceTransport): """gRPC AsyncIO backend transport for VideoIntelligenceService. @@ -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 @@ -254,7 +339,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 annotate_video( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "annotate_video" not in self._stubs: - self._stubs["annotate_video"] = self.grpc_channel.unary_unary( + self._stubs["annotate_video"] = self._logged_channel.unary_unary( "/google.cloud.videointelligence.v1beta2.VideoIntelligenceService/AnnotateVideo", request_serializer=video_intelligence.AnnotateVideoRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -318,7 +403,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-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/transports/rest.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/transports/rest.py index dfd0783333af..ecfec18ca101 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/transports/rest.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_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, @@ -78,8 +86,10 @@ def post_annotate_video(self, response): def pre_annotate_video( self, request: video_intelligence.AnnotateVideoRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[video_intelligence.AnnotateVideoRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_intelligence.AnnotateVideoRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for annotate_video Override in a subclass to manipulate the request or metadata @@ -287,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]]] = (), ) -> operations_pb2.Operation: r"""Call the annotate video method over HTTP. @@ -297,8 +307,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -311,6 +323,7 @@ def __call__( http_options = ( _BaseVideoIntelligenceServiceRestTransport._BaseAnnotateVideo._get_http_options() ) + request, metadata = self._interceptor.pre_annotate_video(request, metadata) transcoded_request = _BaseVideoIntelligenceServiceRestTransport._BaseAnnotateVideo._get_transcoded_request( http_options, request @@ -325,6 +338,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.videointelligence_v1beta2.VideoIntelligenceServiceClient.AnnotateVideo", + extra={ + "serviceName": "google.cloud.videointelligence.v1beta2.VideoIntelligenceService", + "rpcName": "AnnotateVideo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VideoIntelligenceServiceRestTransport._AnnotateVideo._get_response( @@ -346,7 +386,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_annotate_video(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.videointelligence_v1beta2.VideoIntelligenceServiceClient.annotate_video", + extra={ + "serviceName": "google.cloud.videointelligence.v1beta2.VideoIntelligenceService", + "rpcName": "AnnotateVideo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/gapic_version.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/gapic_version.py index 2523dfbe9e23..558c8aab67c5 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/gapic_version.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/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-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/async_client.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/async_client.py index b5a88c366ffd..c924363a5545 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/async_client.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_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, VideoIntelligenceServiceTransport from .transports.grpc_asyncio import VideoIntelligenceServiceGrpcAsyncIOTransport +try: + from google.api_core import client_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 VideoIntelligenceServiceAsyncClient: """Service that implements Google Cloud Video Intelligence API.""" @@ -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.videointelligence_v1p1beta1.VideoIntelligenceServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.videointelligence.v1p1beta1.VideoIntelligenceService", + "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.videointelligence.v1p1beta1.VideoIntelligenceService", + "credentialsType": None, + }, + ) + async def annotate_video( self, request: Optional[Union[video_intelligence.AnnotateVideoRequest, dict]] = None, @@ -272,7 +304,7 @@ async def annotate_video( features: Optional[MutableSequence[video_intelligence.Feature]] = None, retry: OptionalRetry = gapic_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"""Performs asynchronous video annotation. Progress and results can be retrieved through the ``google.longrunning.Operations`` @@ -342,8 +374,10 @@ async def sample_annotate_video(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/client.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/client.py index a46a045ac051..c41f9af5be61 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/client.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_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 @@ -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.videointelligence_v1p1beta1.VideoIntelligenceServiceClient`.", + extra={ + "serviceName": "google.cloud.videointelligence.v1p1beta1.VideoIntelligenceService", + "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.videointelligence.v1p1beta1.VideoIntelligenceService", + "credentialsType": None, + }, + ) + def annotate_video( self, request: Optional[Union[video_intelligence.AnnotateVideoRequest, dict]] = None, @@ -640,7 +677,7 @@ def annotate_video( features: Optional[MutableSequence[video_intelligence.Feature]] = None, retry: OptionalRetry = gapic_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"""Performs asynchronous video annotation. Progress and results can be retrieved through the ``google.longrunning.Operations`` @@ -710,8 +747,10 @@ def sample_annotate_video(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/transports/grpc.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/transports/grpc.py index 5de0f73002c8..bb9bb0d048d7 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/transports/grpc.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_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.videointelligence_v1p1beta1.types import video_intelligence from .base import DEFAULT_CLIENT_INFO, VideoIntelligenceServiceTransport +try: + from google.api_core import client_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.videointelligence.v1p1beta1.VideoIntelligenceService", + "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.videointelligence.v1p1beta1.VideoIntelligenceService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VideoIntelligenceServiceGrpcTransport(VideoIntelligenceServiceTransport): """gRPC backend transport for VideoIntelligenceService. @@ -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 @@ -245,7 +331,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 annotate_video( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "annotate_video" not in self._stubs: - self._stubs["annotate_video"] = self.grpc_channel.unary_unary( + self._stubs["annotate_video"] = self._logged_channel.unary_unary( "/google.cloud.videointelligence.v1p1beta1.VideoIntelligenceService/AnnotateVideo", request_serializer=video_intelligence.AnnotateVideoRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -281,7 +369,7 @@ def annotate_video( return self._stubs["annotate_video"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/transports/grpc_asyncio.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/transports/grpc_asyncio.py index 9ddfda34e2bf..38bb47960533 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_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.videointelligence_v1p1beta1.types import video_intelligence from .base import DEFAULT_CLIENT_INFO, VideoIntelligenceServiceTransport from .grpc import VideoIntelligenceServiceGrpcTransport +try: + from google.api_core import client_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.videointelligence.v1p1beta1.VideoIntelligenceService", + "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.videointelligence.v1p1beta1.VideoIntelligenceService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VideoIntelligenceServiceGrpcAsyncIOTransport(VideoIntelligenceServiceTransport): """gRPC AsyncIO backend transport for VideoIntelligenceService. @@ -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 @@ -254,7 +339,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 annotate_video( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "annotate_video" not in self._stubs: - self._stubs["annotate_video"] = self.grpc_channel.unary_unary( + self._stubs["annotate_video"] = self._logged_channel.unary_unary( "/google.cloud.videointelligence.v1p1beta1.VideoIntelligenceService/AnnotateVideo", request_serializer=video_intelligence.AnnotateVideoRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -318,7 +403,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-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/transports/rest.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/transports/rest.py index 9d690d5afce8..473bbebeb681 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/transports/rest.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_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, @@ -78,8 +86,10 @@ def post_annotate_video(self, response): def pre_annotate_video( self, request: video_intelligence.AnnotateVideoRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[video_intelligence.AnnotateVideoRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_intelligence.AnnotateVideoRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for annotate_video Override in a subclass to manipulate the request or metadata @@ -287,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]]] = (), ) -> operations_pb2.Operation: r"""Call the annotate video method over HTTP. @@ -297,8 +307,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -311,6 +323,7 @@ def __call__( http_options = ( _BaseVideoIntelligenceServiceRestTransport._BaseAnnotateVideo._get_http_options() ) + request, metadata = self._interceptor.pre_annotate_video(request, metadata) transcoded_request = _BaseVideoIntelligenceServiceRestTransport._BaseAnnotateVideo._get_transcoded_request( http_options, request @@ -325,6 +338,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.videointelligence_v1p1beta1.VideoIntelligenceServiceClient.AnnotateVideo", + extra={ + "serviceName": "google.cloud.videointelligence.v1p1beta1.VideoIntelligenceService", + "rpcName": "AnnotateVideo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VideoIntelligenceServiceRestTransport._AnnotateVideo._get_response( @@ -346,7 +386,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_annotate_video(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.videointelligence_v1p1beta1.VideoIntelligenceServiceClient.annotate_video", + extra={ + "serviceName": "google.cloud.videointelligence.v1p1beta1.VideoIntelligenceService", + "rpcName": "AnnotateVideo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/gapic_version.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/gapic_version.py index 2523dfbe9e23..558c8aab67c5 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/gapic_version.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/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-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/async_client.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/async_client.py index d3bf9c203da8..fa81290fee29 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/async_client.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_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, VideoIntelligenceServiceTransport from .transports.grpc_asyncio import VideoIntelligenceServiceGrpcAsyncIOTransport +try: + from google.api_core import client_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 VideoIntelligenceServiceAsyncClient: """Service that implements Google Cloud Video Intelligence API.""" @@ -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.videointelligence_v1p2beta1.VideoIntelligenceServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.videointelligence.v1p2beta1.VideoIntelligenceService", + "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.videointelligence.v1p2beta1.VideoIntelligenceService", + "credentialsType": None, + }, + ) + async def annotate_video( self, request: Optional[Union[video_intelligence.AnnotateVideoRequest, dict]] = None, @@ -272,7 +304,7 @@ async def annotate_video( features: Optional[MutableSequence[video_intelligence.Feature]] = None, retry: OptionalRetry = gapic_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"""Performs asynchronous video annotation. Progress and results can be retrieved through the ``google.longrunning.Operations`` @@ -342,8 +374,10 @@ async def sample_annotate_video(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/client.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/client.py index 95bac44c8cba..067889ada479 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/client.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_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 @@ -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.videointelligence_v1p2beta1.VideoIntelligenceServiceClient`.", + extra={ + "serviceName": "google.cloud.videointelligence.v1p2beta1.VideoIntelligenceService", + "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.videointelligence.v1p2beta1.VideoIntelligenceService", + "credentialsType": None, + }, + ) + def annotate_video( self, request: Optional[Union[video_intelligence.AnnotateVideoRequest, dict]] = None, @@ -640,7 +677,7 @@ def annotate_video( features: Optional[MutableSequence[video_intelligence.Feature]] = None, retry: OptionalRetry = gapic_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"""Performs asynchronous video annotation. Progress and results can be retrieved through the ``google.longrunning.Operations`` @@ -710,8 +747,10 @@ def sample_annotate_video(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/transports/grpc.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/transports/grpc.py index fcf763638e1e..9d73373d3566 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/transports/grpc.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_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.videointelligence_v1p2beta1.types import video_intelligence from .base import DEFAULT_CLIENT_INFO, VideoIntelligenceServiceTransport +try: + from google.api_core import client_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.videointelligence.v1p2beta1.VideoIntelligenceService", + "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.videointelligence.v1p2beta1.VideoIntelligenceService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VideoIntelligenceServiceGrpcTransport(VideoIntelligenceServiceTransport): """gRPC backend transport for VideoIntelligenceService. @@ -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 @@ -245,7 +331,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 annotate_video( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "annotate_video" not in self._stubs: - self._stubs["annotate_video"] = self.grpc_channel.unary_unary( + self._stubs["annotate_video"] = self._logged_channel.unary_unary( "/google.cloud.videointelligence.v1p2beta1.VideoIntelligenceService/AnnotateVideo", request_serializer=video_intelligence.AnnotateVideoRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -281,7 +369,7 @@ def annotate_video( return self._stubs["annotate_video"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/transports/grpc_asyncio.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/transports/grpc_asyncio.py index 5119cccaae32..f01a380f2207 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_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.videointelligence_v1p2beta1.types import video_intelligence from .base import DEFAULT_CLIENT_INFO, VideoIntelligenceServiceTransport from .grpc import VideoIntelligenceServiceGrpcTransport +try: + from google.api_core import client_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.videointelligence.v1p2beta1.VideoIntelligenceService", + "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.videointelligence.v1p2beta1.VideoIntelligenceService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VideoIntelligenceServiceGrpcAsyncIOTransport(VideoIntelligenceServiceTransport): """gRPC AsyncIO backend transport for VideoIntelligenceService. @@ -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 @@ -254,7 +339,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 annotate_video( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "annotate_video" not in self._stubs: - self._stubs["annotate_video"] = self.grpc_channel.unary_unary( + self._stubs["annotate_video"] = self._logged_channel.unary_unary( "/google.cloud.videointelligence.v1p2beta1.VideoIntelligenceService/AnnotateVideo", request_serializer=video_intelligence.AnnotateVideoRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -318,7 +403,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-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/transports/rest.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/transports/rest.py index 3690efd18d20..18ee902a0f73 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/transports/rest.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_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, @@ -78,8 +86,10 @@ def post_annotate_video(self, response): def pre_annotate_video( self, request: video_intelligence.AnnotateVideoRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[video_intelligence.AnnotateVideoRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_intelligence.AnnotateVideoRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for annotate_video Override in a subclass to manipulate the request or metadata @@ -287,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]]] = (), ) -> operations_pb2.Operation: r"""Call the annotate video method over HTTP. @@ -297,8 +307,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -311,6 +323,7 @@ def __call__( http_options = ( _BaseVideoIntelligenceServiceRestTransport._BaseAnnotateVideo._get_http_options() ) + request, metadata = self._interceptor.pre_annotate_video(request, metadata) transcoded_request = _BaseVideoIntelligenceServiceRestTransport._BaseAnnotateVideo._get_transcoded_request( http_options, request @@ -325,6 +338,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.videointelligence_v1p2beta1.VideoIntelligenceServiceClient.AnnotateVideo", + extra={ + "serviceName": "google.cloud.videointelligence.v1p2beta1.VideoIntelligenceService", + "rpcName": "AnnotateVideo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VideoIntelligenceServiceRestTransport._AnnotateVideo._get_response( @@ -346,7 +386,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_annotate_video(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.videointelligence_v1p2beta1.VideoIntelligenceServiceClient.annotate_video", + extra={ + "serviceName": "google.cloud.videointelligence.v1p2beta1.VideoIntelligenceService", + "rpcName": "AnnotateVideo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/gapic_version.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/gapic_version.py index 2523dfbe9e23..558c8aab67c5 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/gapic_version.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/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-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/async_client.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/async_client.py index 954fef29f5d3..dd0ac9794b00 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/async_client.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_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 ( AsyncIterable, @@ -58,6 +59,15 @@ StreamingVideoIntelligenceServiceGrpcAsyncIOTransport, ) +try: + from google.api_core import client_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 StreamingVideoIntelligenceServiceAsyncClient: """Service that implements streaming Video Intelligence API.""" @@ -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.videointelligence_v1p3beta1.StreamingVideoIntelligenceServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceService", + "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.videointelligence.v1p3beta1.StreamingVideoIntelligenceService", + "credentialsType": None, + }, + ) + def streaming_annotate_video( self, requests: Optional[ @@ -283,7 +315,7 @@ def streaming_annotate_video( *, retry: OptionalRetry = 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[video_intelligence.StreamingAnnotateVideoResponse]]: r"""Performs video annotation with bidirectional streaming: emitting results while sending video/audio @@ -337,8 +369,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.videointelligence_v1p3beta1.types.StreamingAnnotateVideoResponse]: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/client.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/client.py index 73616a417b7b..854840dace8e 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/client.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_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 ( @@ -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.rpc import status_pb2 # type: ignore from google.cloud.videointelligence_v1p3beta1.types import video_intelligence @@ -576,6 +586,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.videointelligence_v1p3beta1.StreamingVideoIntelligenceServiceClient`.", + extra={ + "serviceName": "google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceService", + "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.videointelligence.v1p3beta1.StreamingVideoIntelligenceService", + "credentialsType": None, + }, + ) + def streaming_annotate_video( self, requests: Optional[ @@ -656,7 +693,7 @@ def streaming_annotate_video( *, retry: OptionalRetry = 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[video_intelligence.StreamingAnnotateVideoResponse]: r"""Performs video annotation with bidirectional streaming: emitting results while sending video/audio @@ -710,8 +747,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.videointelligence_v1p3beta1.types.StreamingAnnotateVideoResponse]: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/transports/grpc.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/transports/grpc.py index 9ef7433f7a28..78fa164e0e6c 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/transports/grpc.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_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.cloud.videointelligence_v1p3beta1.types import video_intelligence from .base import DEFAULT_CLIENT_INFO, StreamingVideoIntelligenceServiceTransport +try: + from google.api_core import client_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.videointelligence.v1p3beta1.StreamingVideoIntelligenceService", + "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.videointelligence.v1p3beta1.StreamingVideoIntelligenceService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StreamingVideoIntelligenceServiceGrpcTransport( StreamingVideoIntelligenceServiceTransport @@ -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 @@ -261,7 +347,9 @@ def streaming_annotate_video( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "streaming_annotate_video" not in self._stubs: - self._stubs["streaming_annotate_video"] = self.grpc_channel.stream_stream( + self._stubs[ + "streaming_annotate_video" + ] = self._logged_channel.stream_stream( "/google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceService/StreamingAnnotateVideo", request_serializer=video_intelligence.StreamingAnnotateVideoRequest.serialize, response_deserializer=video_intelligence.StreamingAnnotateVideoResponse.deserialize, @@ -269,7 +357,7 @@ def streaming_annotate_video( return self._stubs["streaming_annotate_video"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/transports/grpc_asyncio.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/transports/grpc_asyncio.py index 5b4e00989830..07d0c3ecbf24 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_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.cloud.videointelligence_v1p3beta1.types import video_intelligence from .base import DEFAULT_CLIENT_INFO, StreamingVideoIntelligenceServiceTransport from .grpc import StreamingVideoIntelligenceServiceGrpcTransport +try: + from google.api_core import client_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.videointelligence.v1p3beta1.StreamingVideoIntelligenceService", + "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.videointelligence.v1p3beta1.StreamingVideoIntelligenceService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StreamingVideoIntelligenceServiceGrpcAsyncIOTransport( StreamingVideoIntelligenceServiceTransport @@ -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 @@ -269,7 +354,9 @@ def streaming_annotate_video( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "streaming_annotate_video" not in self._stubs: - self._stubs["streaming_annotate_video"] = self.grpc_channel.stream_stream( + self._stubs[ + "streaming_annotate_video" + ] = self._logged_channel.stream_stream( "/google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceService/StreamingAnnotateVideo", request_serializer=video_intelligence.StreamingAnnotateVideoRequest.serialize, response_deserializer=video_intelligence.StreamingAnnotateVideoResponse.deserialize, @@ -302,7 +389,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-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/async_client.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/async_client.py index 002f73484ccb..8d4555b51335 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/async_client.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_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, VideoIntelligenceServiceTransport from .transports.grpc_asyncio import VideoIntelligenceServiceGrpcAsyncIOTransport +try: + from google.api_core import client_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 VideoIntelligenceServiceAsyncClient: """Service that implements the Video Intelligence API.""" @@ -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.videointelligence_v1p3beta1.VideoIntelligenceServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.videointelligence.v1p3beta1.VideoIntelligenceService", + "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.videointelligence.v1p3beta1.VideoIntelligenceService", + "credentialsType": None, + }, + ) + async def annotate_video( self, request: Optional[Union[video_intelligence.AnnotateVideoRequest, dict]] = None, @@ -272,7 +304,7 @@ async def annotate_video( features: Optional[MutableSequence[video_intelligence.Feature]] = None, retry: OptionalRetry = gapic_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"""Performs asynchronous video annotation. Progress and results can be retrieved through the ``google.longrunning.Operations`` @@ -342,8 +374,10 @@ async def sample_annotate_video(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/client.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/client.py index 8224567a519b..c67589a85a2c 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/client.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_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 @@ -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.videointelligence_v1p3beta1.VideoIntelligenceServiceClient`.", + extra={ + "serviceName": "google.cloud.videointelligence.v1p3beta1.VideoIntelligenceService", + "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.videointelligence.v1p3beta1.VideoIntelligenceService", + "credentialsType": None, + }, + ) + def annotate_video( self, request: Optional[Union[video_intelligence.AnnotateVideoRequest, dict]] = None, @@ -638,7 +675,7 @@ def annotate_video( features: Optional[MutableSequence[video_intelligence.Feature]] = None, retry: OptionalRetry = gapic_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"""Performs asynchronous video annotation. Progress and results can be retrieved through the ``google.longrunning.Operations`` @@ -708,8 +745,10 @@ def sample_annotate_video(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/transports/grpc.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/transports/grpc.py index 1c772bb4b634..f5b7be999d7a 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/transports/grpc.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_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.videointelligence_v1p3beta1.types import video_intelligence from .base import DEFAULT_CLIENT_INFO, VideoIntelligenceServiceTransport +try: + from google.api_core import client_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.videointelligence.v1p3beta1.VideoIntelligenceService", + "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.videointelligence.v1p3beta1.VideoIntelligenceService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VideoIntelligenceServiceGrpcTransport(VideoIntelligenceServiceTransport): """gRPC backend transport for VideoIntelligenceService. @@ -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 @@ -245,7 +331,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 annotate_video( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "annotate_video" not in self._stubs: - self._stubs["annotate_video"] = self.grpc_channel.unary_unary( + self._stubs["annotate_video"] = self._logged_channel.unary_unary( "/google.cloud.videointelligence.v1p3beta1.VideoIntelligenceService/AnnotateVideo", request_serializer=video_intelligence.AnnotateVideoRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -281,7 +369,7 @@ def annotate_video( return self._stubs["annotate_video"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/transports/grpc_asyncio.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/transports/grpc_asyncio.py index a12e77d64aea..81eddfd672dd 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_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.videointelligence_v1p3beta1.types import video_intelligence from .base import DEFAULT_CLIENT_INFO, VideoIntelligenceServiceTransport from .grpc import VideoIntelligenceServiceGrpcTransport +try: + from google.api_core import client_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.videointelligence.v1p3beta1.VideoIntelligenceService", + "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.videointelligence.v1p3beta1.VideoIntelligenceService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VideoIntelligenceServiceGrpcAsyncIOTransport(VideoIntelligenceServiceTransport): """gRPC AsyncIO backend transport for VideoIntelligenceService. @@ -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 @@ -254,7 +339,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 annotate_video( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "annotate_video" not in self._stubs: - self._stubs["annotate_video"] = self.grpc_channel.unary_unary( + self._stubs["annotate_video"] = self._logged_channel.unary_unary( "/google.cloud.videointelligence.v1p3beta1.VideoIntelligenceService/AnnotateVideo", request_serializer=video_intelligence.AnnotateVideoRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -318,7 +403,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-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1.json b/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1.json index 1737a6d46ac6..e198e62e8a23 100644 --- a/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1.json +++ b/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-videointelligence", - "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", diff --git a/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1beta2.json b/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1beta2.json index b5dc9f4a37e0..3f3ec25e9b73 100644 --- a/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1beta2.json +++ b/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1beta2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-videointelligence", - "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", diff --git a/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1p1beta1.json b/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1p1beta1.json index be02fff47af4..99531c7a7090 100644 --- a/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1p1beta1.json +++ b/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1p1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-videointelligence", - "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", diff --git a/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1p2beta1.json b/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1p2beta1.json index b995488fce46..5fad06591e51 100644 --- a/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1p2beta1.json +++ b/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1p2beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-videointelligence", - "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", diff --git a/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1p3beta1.json b/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1p3beta1.json index 5a911d4aef3f..b409a29f032a 100644 --- a/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1p3beta1.json +++ b/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1p3beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-videointelligence", - "version": "2.14.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": "Iterable[google.cloud.videointelligence_v1p3beta1.types.StreamingAnnotateVideoResponse]", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.videointelligence_v1p3beta1.types.StreamingAnnotateVideoResponse]", @@ -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", diff --git a/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1/test_video_intelligence_service.py b/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1/test_video_intelligence_service.py index 4c67b5e35250..abe1746b3ca4 100644 --- a/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1/test_video_intelligence_service.py +++ b/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1/test_video_intelligence_service.py @@ -1520,6 +1520,7 @@ def test_annotate_video_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.annotate_video(request) @@ -1564,6 +1565,7 @@ def test_annotate_video_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.annotate_video(**mock_args) @@ -1786,6 +1788,7 @@ def test_annotate_video_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.annotate_video(request) @@ -1816,6 +1819,7 @@ def test_annotate_video_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.annotate_video(request) # Establish that the response is the type that we expect. @@ -1857,6 +1861,7 @@ def test_annotate_video_rest_interceptors(null_interceptor): req.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-videointelligence/tests/unit/gapic/videointelligence_v1beta2/test_video_intelligence_service.py b/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1beta2/test_video_intelligence_service.py index 905fb61e115b..326527bea4a5 100644 --- a/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1beta2/test_video_intelligence_service.py +++ b/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1beta2/test_video_intelligence_service.py @@ -1520,6 +1520,7 @@ def test_annotate_video_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.annotate_video(request) @@ -1564,6 +1565,7 @@ def test_annotate_video_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.annotate_video(**mock_args) @@ -1786,6 +1788,7 @@ def test_annotate_video_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.annotate_video(request) @@ -1816,6 +1819,7 @@ def test_annotate_video_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.annotate_video(request) # Establish that the response is the type that we expect. @@ -1857,6 +1861,7 @@ def test_annotate_video_rest_interceptors(null_interceptor): req.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-videointelligence/tests/unit/gapic/videointelligence_v1p1beta1/test_video_intelligence_service.py b/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1p1beta1/test_video_intelligence_service.py index 77057a7c6aa3..ed326cef6887 100644 --- a/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1p1beta1/test_video_intelligence_service.py +++ b/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1p1beta1/test_video_intelligence_service.py @@ -1520,6 +1520,7 @@ def test_annotate_video_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.annotate_video(request) @@ -1564,6 +1565,7 @@ def test_annotate_video_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.annotate_video(**mock_args) @@ -1786,6 +1788,7 @@ def test_annotate_video_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.annotate_video(request) @@ -1816,6 +1819,7 @@ def test_annotate_video_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.annotate_video(request) # Establish that the response is the type that we expect. @@ -1857,6 +1861,7 @@ def test_annotate_video_rest_interceptors(null_interceptor): req.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-videointelligence/tests/unit/gapic/videointelligence_v1p2beta1/test_video_intelligence_service.py b/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1p2beta1/test_video_intelligence_service.py index cb8325fc463d..1c49e3264c22 100644 --- a/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1p2beta1/test_video_intelligence_service.py +++ b/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1p2beta1/test_video_intelligence_service.py @@ -1520,6 +1520,7 @@ def test_annotate_video_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.annotate_video(request) @@ -1564,6 +1565,7 @@ def test_annotate_video_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.annotate_video(**mock_args) @@ -1786,6 +1788,7 @@ def test_annotate_video_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.annotate_video(request) @@ -1816,6 +1819,7 @@ def test_annotate_video_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.annotate_video(request) # Establish that the response is the type that we expect. @@ -1857,6 +1861,7 @@ def test_annotate_video_rest_interceptors(null_interceptor): req.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-vision/google/cloud/vision/gapic_version.py b/packages/google-cloud-vision/google/cloud/vision/gapic_version.py index e194ca38362b..558c8aab67c5 100644 --- a/packages/google-cloud-vision/google/cloud/vision/gapic_version.py +++ b/packages/google-cloud-vision/google/cloud/vision/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.8.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vision/google/cloud/vision_v1/gapic_version.py b/packages/google-cloud-vision/google/cloud/vision_v1/gapic_version.py index e194ca38362b..558c8aab67c5 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1/gapic_version.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.8.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/async_client.py b/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/async_client.py index 7977f25d0c15..300f4cce72b5 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/async_client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/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, @@ -52,6 +53,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport from .transports.grpc_asyncio import ImageAnnotatorGrpcAsyncIOTransport +try: + from google.api_core import client_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 ImageAnnotatorAsyncClient: """Service that performs Google Cloud Vision API detection tasks @@ -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.vision_v1.ImageAnnotatorAsyncClient`.", + extra={ + "serviceName": "google.cloud.vision.v1.ImageAnnotator", + "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.vision.v1.ImageAnnotator", + "credentialsType": None, + }, + ) + async def batch_annotate_images( self, request: Optional[ @@ -274,7 +306,7 @@ async def batch_annotate_images( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Run image detection and annotation for a batch of images. @@ -318,8 +350,10 @@ async def sample_batch_annotate_images(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1.types.BatchAnnotateImagesResponse: @@ -376,7 +410,7 @@ async def batch_annotate_files( requests: Optional[MutableSequence[image_annotator.AnnotateFileRequest]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateFilesResponse: r"""Service that performs image detection and annotation for a batch of files. Now only "application/pdf", @@ -429,8 +463,10 @@ async def sample_batch_annotate_files(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1.types.BatchAnnotateFilesResponse: @@ -488,7 +524,7 @@ async def async_batch_annotate_images( output_config: Optional[image_annotator.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"""Run asynchronous image detection and annotation for a list of images. @@ -553,8 +589,10 @@ async def sample_async_batch_annotate_images(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -626,7 +664,7 @@ async def async_batch_annotate_files( ] = None, retry: OptionalRetry = gapic_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"""Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple @@ -680,8 +718,10 @@ async def sample_async_batch_annotate_files(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -746,7 +786,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. @@ -757,8 +797,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-cloud-vision/google/cloud/vision_v1/services/image_annotator/client.py b/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/client.py index 8a91bfc7a82a..d6412d5acdb5 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/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 @@ -609,6 +619,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( @@ -674,6 +688,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.vision_v1.ImageAnnotatorClient`.", + extra={ + "serviceName": "google.cloud.vision.v1.ImageAnnotator", + "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.vision.v1.ImageAnnotator", + "credentialsType": None, + }, + ) + def batch_annotate_images( self, request: Optional[ @@ -685,7 +722,7 @@ def batch_annotate_images( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Run image detection and annotation for a batch of images. @@ -729,8 +766,10 @@ def sample_batch_annotate_images(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1.types.BatchAnnotateImagesResponse: @@ -784,7 +823,7 @@ def batch_annotate_files( requests: Optional[MutableSequence[image_annotator.AnnotateFileRequest]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateFilesResponse: r"""Service that performs image detection and annotation for a batch of files. Now only "application/pdf", @@ -837,8 +876,10 @@ def sample_batch_annotate_files(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1.types.BatchAnnotateFilesResponse: @@ -893,7 +934,7 @@ def async_batch_annotate_images( output_config: Optional[image_annotator.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"""Run asynchronous image detection and annotation for a list of images. @@ -958,8 +999,10 @@ def sample_async_batch_annotate_images(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1030,7 +1073,7 @@ def async_batch_annotate_files( ] = None, retry: OptionalRetry = gapic_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"""Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple @@ -1084,8 +1127,10 @@ def sample_async_batch_annotate_files(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1162,7 +1207,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. @@ -1173,8 +1218,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-cloud-vision/google/cloud/vision_v1/services/image_annotator/transports/grpc.py b/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/transports/grpc.py index 4d2627563cc7..787d3832ccbb 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/transports/grpc.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/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.vision_v1.types import image_annotator from .base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport +try: + from google.api_core import client_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.vision.v1.ImageAnnotator", + "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.vision.v1.ImageAnnotator", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ImageAnnotatorGrpcTransport(ImageAnnotatorTransport): """gRPC backend transport for ImageAnnotator. @@ -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 @@ -276,7 +364,7 @@ def batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_images" not in self._stubs: - self._stubs["batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ImageAnnotator/BatchAnnotateImages", request_serializer=image_annotator.BatchAnnotateImagesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateImagesResponse.deserialize, @@ -313,7 +401,7 @@ def batch_annotate_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_files" not in self._stubs: - self._stubs["batch_annotate_files"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_files"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ImageAnnotator/BatchAnnotateFiles", request_serializer=image_annotator.BatchAnnotateFilesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateFilesResponse.deserialize, @@ -352,7 +440,9 @@ def async_batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "async_batch_annotate_images" not in self._stubs: - self._stubs["async_batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs[ + "async_batch_annotate_images" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ImageAnnotator/AsyncBatchAnnotateImages", request_serializer=image_annotator.AsyncBatchAnnotateImagesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -386,7 +476,9 @@ def async_batch_annotate_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "async_batch_annotate_files" not in self._stubs: - self._stubs["async_batch_annotate_files"] = self.grpc_channel.unary_unary( + self._stubs[ + "async_batch_annotate_files" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ImageAnnotator/AsyncBatchAnnotateFiles", request_serializer=image_annotator.AsyncBatchAnnotateFilesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -394,7 +486,7 @@ def async_batch_annotate_files( return self._stubs["async_batch_annotate_files"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -406,7 +498,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-cloud-vision/google/cloud/vision_v1/services/image_annotator/transports/grpc_asyncio.py b/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/transports/grpc_asyncio.py index ab225ab52338..e937b2d873c4 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/transports/grpc_asyncio.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/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.vision_v1.types import image_annotator from .base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport from .grpc import ImageAnnotatorGrpcTransport +try: + from google.api_core import client_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.vision.v1.ImageAnnotator", + "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.vision.v1.ImageAnnotator", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ImageAnnotatorGrpcAsyncIOTransport(ImageAnnotatorTransport): """gRPC AsyncIO backend transport for ImageAnnotator. @@ -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. @@ -286,7 +371,7 @@ def batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_images" not in self._stubs: - self._stubs["batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ImageAnnotator/BatchAnnotateImages", request_serializer=image_annotator.BatchAnnotateImagesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateImagesResponse.deserialize, @@ -323,7 +408,7 @@ def batch_annotate_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_files" not in self._stubs: - self._stubs["batch_annotate_files"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_files"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ImageAnnotator/BatchAnnotateFiles", request_serializer=image_annotator.BatchAnnotateFilesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateFilesResponse.deserialize, @@ -363,7 +448,9 @@ def async_batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "async_batch_annotate_images" not in self._stubs: - self._stubs["async_batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs[ + "async_batch_annotate_images" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ImageAnnotator/AsyncBatchAnnotateImages", request_serializer=image_annotator.AsyncBatchAnnotateImagesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -398,7 +485,9 @@ def async_batch_annotate_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "async_batch_annotate_files" not in self._stubs: - self._stubs["async_batch_annotate_files"] = self.grpc_channel.unary_unary( + self._stubs[ + "async_batch_annotate_files" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ImageAnnotator/AsyncBatchAnnotateFiles", request_serializer=image_annotator.AsyncBatchAnnotateFilesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -481,7 +570,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: @@ -497,7 +586,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-cloud-vision/google/cloud/vision_v1/services/image_annotator/transports/rest.py b/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/transports/rest.py index 49fa4a5aced3..cf7fb6976885 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/transports/rest.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/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, @@ -102,9 +110,10 @@ def post_batch_annotate_images(self, response): def pre_async_batch_annotate_files( self, request: image_annotator.AsyncBatchAnnotateFilesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - image_annotator.AsyncBatchAnnotateFilesRequest, Sequence[Tuple[str, str]] + image_annotator.AsyncBatchAnnotateFilesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for async_batch_annotate_files @@ -127,9 +136,10 @@ def post_async_batch_annotate_files( def pre_async_batch_annotate_images( self, request: image_annotator.AsyncBatchAnnotateImagesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - image_annotator.AsyncBatchAnnotateImagesRequest, Sequence[Tuple[str, str]] + image_annotator.AsyncBatchAnnotateImagesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for async_batch_annotate_images @@ -152,8 +162,11 @@ def post_async_batch_annotate_images( def pre_batch_annotate_files( self, request: image_annotator.BatchAnnotateFilesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[image_annotator.BatchAnnotateFilesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + image_annotator.BatchAnnotateFilesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_annotate_files Override in a subclass to manipulate the request or metadata @@ -175,8 +188,11 @@ def post_batch_annotate_files( def pre_batch_annotate_images( self, request: image_annotator.BatchAnnotateImagesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[image_annotator.BatchAnnotateImagesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + image_annotator.BatchAnnotateImagesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_annotate_images Override in a subclass to manipulate the request or metadata @@ -198,8 +214,10 @@ def post_batch_annotate_images( 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 @@ -391,7 +409,7 @@ 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 async batch annotate files method over HTTP. @@ -404,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: ~.operations_pb2.Operation: @@ -418,6 +438,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseAsyncBatchAnnotateFiles._get_http_options() ) + request, metadata = self._interceptor.pre_async_batch_annotate_files( request, metadata ) @@ -434,6 +455,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1.ImageAnnotatorClient.AsyncBatchAnnotateFiles", + extra={ + "serviceName": "google.cloud.vision.v1.ImageAnnotator", + "rpcName": "AsyncBatchAnnotateFiles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ImageAnnotatorRestTransport._AsyncBatchAnnotateFiles._get_response( @@ -455,7 +503,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_async_batch_annotate_files(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1.ImageAnnotatorClient.async_batch_annotate_files", + extra={ + "serviceName": "google.cloud.vision.v1.ImageAnnotator", + "rpcName": "AsyncBatchAnnotateFiles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AsyncBatchAnnotateImages( @@ -494,7 +564,7 @@ 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 async batch annotate images method over HTTP. @@ -506,8 +576,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -520,6 +592,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseAsyncBatchAnnotateImages._get_http_options() ) + request, metadata = self._interceptor.pre_async_batch_annotate_images( request, metadata ) @@ -536,6 +609,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1.ImageAnnotatorClient.AsyncBatchAnnotateImages", + extra={ + "serviceName": "google.cloud.vision.v1.ImageAnnotator", + "rpcName": "AsyncBatchAnnotateImages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ImageAnnotatorRestTransport._AsyncBatchAnnotateImages._get_response( @@ -557,7 +657,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_async_batch_annotate_images(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1.ImageAnnotatorClient.async_batch_annotate_images", + extra={ + "serviceName": "google.cloud.vision.v1.ImageAnnotator", + "rpcName": "AsyncBatchAnnotateImages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchAnnotateFiles( @@ -595,7 +717,7 @@ 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_annotator.BatchAnnotateFilesResponse: r"""Call the batch annotate files method over HTTP. @@ -606,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: ~.image_annotator.BatchAnnotateFilesResponse: @@ -617,6 +741,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseBatchAnnotateFiles._get_http_options() ) + request, metadata = self._interceptor.pre_batch_annotate_files( request, metadata ) @@ -633,6 +758,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1.ImageAnnotatorClient.BatchAnnotateFiles", + extra={ + "serviceName": "google.cloud.vision.v1.ImageAnnotator", + "rpcName": "BatchAnnotateFiles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImageAnnotatorRestTransport._BatchAnnotateFiles._get_response( self._host, @@ -654,7 +806,31 @@ def __call__( pb_resp = image_annotator.BatchAnnotateFilesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_annotate_files(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + image_annotator.BatchAnnotateFilesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1.ImageAnnotatorClient.batch_annotate_files", + extra={ + "serviceName": "google.cloud.vision.v1.ImageAnnotator", + "rpcName": "BatchAnnotateFiles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchAnnotateImages( @@ -693,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]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Call the batch annotate images method over HTTP. @@ -704,8 +880,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_annotator.BatchAnnotateImagesResponse: @@ -717,6 +895,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseBatchAnnotateImages._get_http_options() ) + request, metadata = self._interceptor.pre_batch_annotate_images( request, metadata ) @@ -733,6 +912,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1.ImageAnnotatorClient.BatchAnnotateImages", + extra={ + "serviceName": "google.cloud.vision.v1.ImageAnnotator", + "rpcName": "BatchAnnotateImages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImageAnnotatorRestTransport._BatchAnnotateImages._get_response( self._host, @@ -754,7 +960,31 @@ def __call__( pb_resp = image_annotator.BatchAnnotateImagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_annotate_images(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + image_annotator.BatchAnnotateImagesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1.ImageAnnotatorClient.batch_annotate_images", + extra={ + "serviceName": "google.cloud.vision.v1.ImageAnnotator", + "rpcName": "BatchAnnotateImages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -837,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -847,8 +1077,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -857,6 +1089,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseImageAnnotatorRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -867,6 +1100,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1.ImageAnnotatorClient.GetOperation", + extra={ + "serviceName": "google.cloud.vision.v1.ImageAnnotator", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImageAnnotatorRestTransport._GetOperation._get_response( self._host, @@ -886,6 +1146,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.vision_v1.ImageAnnotatorAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.vision.v1.ImageAnnotator", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/async_client.py b/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/async_client.py index ac11eaeaccd7..bc271d167944 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/async_client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/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, ProductSearchTransport from .transports.grpc_asyncio import ProductSearchGrpcAsyncIOTransport +try: + from google.api_core import client_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 ProductSearchAsyncClient: """Manages Products and ProductSets of reference images for use in @@ -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.vision_v1.ProductSearchAsyncClient`.", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "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.vision.v1.ProductSearch", + "credentialsType": None, + }, + ) + async def create_product_set( self, request: Optional[ @@ -297,7 +329,7 @@ async def create_product_set( product_set_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]]] = (), ) -> product_search_service.ProductSet: r"""Creates and returns a new ProductSet resource. @@ -362,8 +394,10 @@ async def sample_create_product_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, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1.types.ProductSet: @@ -433,7 +467,7 @@ async def list_product_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.ListProductSetsAsyncPager: r"""Lists ProductSets in an unspecified order. @@ -484,8 +518,10 @@ async def sample_list_product_sets(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1.services.product_search.pagers.ListProductSetsAsyncPager: @@ -561,7 +597,7 @@ async def get_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Gets information associated with a ProductSet. @@ -610,8 +646,10 @@ async def sample_get_product_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, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1.types.ProductSet: @@ -678,7 +716,7 @@ async def update_product_set( 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]]] = (), ) -> product_search_service.ProductSet: r"""Makes changes to a ProductSet resource. Only display_name can be updated currently. @@ -737,8 +775,10 @@ async def sample_update_product_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, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1.types.ProductSet: @@ -808,7 +848,7 @@ async def delete_product_set( name: Optional[str] = None, retry: OptionalRetry = 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"""Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. @@ -854,8 +894,10 @@ async def sample_delete_product_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, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -911,7 +953,7 @@ async def create_product( product_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]]] = (), ) -> product_search_service.Product: r"""Creates and returns a new product resource. @@ -980,8 +1022,10 @@ async def sample_create_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.cloud.vision_v1.types.Product: @@ -1046,7 +1090,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 products in an unspecified order. @@ -1097,8 +1141,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.cloud.vision_v1.services.product_search.pagers.ListProductsAsyncPager: @@ -1172,7 +1218,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]]] = (), ) -> product_search_service.Product: r"""Gets information associated with a Product. @@ -1221,8 +1267,10 @@ 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.cloud.vision_v1.types.Product: @@ -1284,7 +1332,7 @@ async def update_product( 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]]] = (), ) -> product_search_service.Product: r"""Makes changes to a Product resource. Only the ``display_name``, ``description``, and ``labels`` fields can be updated right now. @@ -1352,8 +1400,10 @@ async def sample_update_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.cloud.vision_v1.types.Product: @@ -1418,7 +1468,7 @@ async def delete_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]]] = (), ) -> None: r"""Permanently deletes a product and its reference images. @@ -1465,8 +1515,10 @@ async def sample_delete_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1522,7 +1574,7 @@ async def create_reference_image( reference_image_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]]] = (), ) -> product_search_service.ReferenceImage: r"""Creates and returns a new ReferenceImage resource. @@ -1611,8 +1663,10 @@ async def sample_create_reference_image(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1.types.ReferenceImage: @@ -1679,7 +1733,7 @@ async def delete_reference_image( name: Optional[str] = None, retry: OptionalRetry = 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"""Permanently deletes a reference image. @@ -1729,8 +1783,10 @@ async def sample_delete_reference_image(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -1784,7 +1840,7 @@ async def list_reference_images( 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.ListReferenceImagesAsyncPager: r"""Lists reference images. @@ -1837,8 +1893,10 @@ async def sample_list_reference_images(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1.services.product_search.pagers.ListReferenceImagesAsyncPager: @@ -1914,7 +1972,7 @@ async def get_reference_image( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Gets information associated with a ReferenceImage. @@ -1964,8 +2022,10 @@ async def sample_get_reference_image(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1.types.ReferenceImage: @@ -2029,7 +2089,7 @@ async def add_product_to_product_set( product: Optional[str] = None, retry: OptionalRetry = 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"""Adds a Product to the specified ProductSet. If the Product is already present, no change is made. @@ -2092,8 +2152,10 @@ async def sample_add_product_to_product_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, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -2152,7 +2214,7 @@ async def remove_product_from_product_set( product: Optional[str] = None, retry: OptionalRetry = 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"""Removes a Product from the specified ProductSet. @@ -2207,8 +2269,10 @@ async def sample_remove_product_from_product_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, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -2266,7 +2330,7 @@ async def list_products_in_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductsInProductSetAsyncPager: r"""Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the @@ -2321,8 +2385,10 @@ async def sample_list_products_in_product_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, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1.services.product_search.pagers.ListProductsInProductSetAsyncPager: @@ -2404,7 +2470,7 @@ async def import_product_sets( ] = None, retry: OptionalRetry = gapic_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"""Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. @@ -2471,8 +2537,10 @@ async def sample_import_product_sets(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2554,7 +2622,7 @@ async def purge_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]]] = (), ) -> operation_async.AsyncOperation: r"""Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. @@ -2629,8 +2697,10 @@ async def sample_purge_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.api_core.operation_async.AsyncOperation: @@ -2708,7 +2778,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. @@ -2719,8 +2789,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-cloud-vision/google/cloud/vision_v1/services/product_search/client.py b/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/client.py index e1a95284428f..030b357a857c 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/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 @@ -650,6 +660,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( @@ -715,6 +729,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.vision_v1.ProductSearchClient`.", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "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.vision.v1.ProductSearch", + "credentialsType": None, + }, + ) + def create_product_set( self, request: Optional[ @@ -726,7 +763,7 @@ def create_product_set( product_set_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]]] = (), ) -> product_search_service.ProductSet: r"""Creates and returns a new ProductSet resource. @@ -791,8 +828,10 @@ def sample_create_product_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.cloud.vision_v1.types.ProductSet: @@ -859,7 +898,7 @@ def list_product_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.ListProductSetsPager: r"""Lists ProductSets in an unspecified order. @@ -910,8 +949,10 @@ def sample_list_product_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.vision_v1.services.product_search.pagers.ListProductSetsPager: @@ -984,7 +1025,7 @@ def get_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Gets information associated with a ProductSet. @@ -1033,8 +1074,10 @@ def sample_get_product_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.cloud.vision_v1.types.ProductSet: @@ -1098,7 +1141,7 @@ def update_product_set( 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]]] = (), ) -> product_search_service.ProductSet: r"""Makes changes to a ProductSet resource. Only display_name can be updated currently. @@ -1157,8 +1200,10 @@ def sample_update_product_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.cloud.vision_v1.types.ProductSet: @@ -1225,7 +1270,7 @@ def delete_product_set( name: Optional[str] = None, retry: OptionalRetry = 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"""Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. @@ -1271,8 +1316,10 @@ def sample_delete_product_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1325,7 +1372,7 @@ def create_product( product_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]]] = (), ) -> product_search_service.Product: r"""Creates and returns a new product resource. @@ -1394,8 +1441,10 @@ def sample_create_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.cloud.vision_v1.types.Product: @@ -1457,7 +1506,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 products in an unspecified order. @@ -1508,8 +1557,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.cloud.vision_v1.services.product_search.pagers.ListProductsPager: @@ -1580,7 +1631,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]]] = (), ) -> product_search_service.Product: r"""Gets information associated with a Product. @@ -1629,8 +1680,10 @@ 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.cloud.vision_v1.types.Product: @@ -1689,7 +1742,7 @@ def update_product( 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]]] = (), ) -> product_search_service.Product: r"""Makes changes to a Product resource. Only the ``display_name``, ``description``, and ``labels`` fields can be updated right now. @@ -1757,8 +1810,10 @@ def sample_update_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.cloud.vision_v1.types.Product: @@ -1820,7 +1875,7 @@ def delete_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]]] = (), ) -> None: r"""Permanently deletes a product and its reference images. @@ -1867,8 +1922,10 @@ def sample_delete_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1921,7 +1978,7 @@ def create_reference_image( reference_image_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]]] = (), ) -> product_search_service.ReferenceImage: r"""Creates and returns a new ReferenceImage resource. @@ -2010,8 +2067,10 @@ def sample_create_reference_image(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1.types.ReferenceImage: @@ -2075,7 +2134,7 @@ def delete_reference_image( name: Optional[str] = None, retry: OptionalRetry = 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"""Permanently deletes a reference image. @@ -2125,8 +2184,10 @@ def sample_delete_reference_image(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -2177,7 +2238,7 @@ def list_reference_images( 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.ListReferenceImagesPager: r"""Lists reference images. @@ -2230,8 +2291,10 @@ def sample_list_reference_images(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1.services.product_search.pagers.ListReferenceImagesPager: @@ -2304,7 +2367,7 @@ def get_reference_image( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Gets information associated with a ReferenceImage. @@ -2354,8 +2417,10 @@ def sample_get_reference_image(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1.types.ReferenceImage: @@ -2416,7 +2481,7 @@ def add_product_to_product_set( product: Optional[str] = None, retry: OptionalRetry = 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"""Adds a Product to the specified ProductSet. If the Product is already present, no change is made. @@ -2479,8 +2544,10 @@ def sample_add_product_to_product_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2538,7 +2605,7 @@ def remove_product_from_product_set( product: Optional[str] = None, retry: OptionalRetry = 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"""Removes a Product from the specified ProductSet. @@ -2593,8 +2660,10 @@ def sample_remove_product_from_product_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2651,7 +2720,7 @@ def list_products_in_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductsInProductSetPager: r"""Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the @@ -2706,8 +2775,10 @@ def sample_list_products_in_product_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.cloud.vision_v1.services.product_search.pagers.ListProductsInProductSetPager: @@ -2788,7 +2859,7 @@ def import_product_sets( ] = None, retry: OptionalRetry = gapic_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"""Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. @@ -2855,8 +2926,10 @@ def sample_import_product_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.api_core.operation.Operation: @@ -2935,7 +3008,7 @@ def purge_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]]] = (), ) -> operation.Operation: r"""Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. @@ -3010,8 +3083,10 @@ def sample_purge_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.api_core.operation.Operation: @@ -3099,7 +3174,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. @@ -3110,8 +3185,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-cloud-vision/google/cloud/vision_v1/services/product_search/pagers.py b/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/pagers.py index bd49207fa3a0..7809b963ea70 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/pagers.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/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 = product_search_service.ListProductSetsRequest(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 = product_search_service.ListProductSetsRequest(request) @@ -223,7 +227,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -237,8 +241,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = product_search_service.ListProductsRequest(request) @@ -297,7 +303,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. @@ -311,8 +317,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 = product_search_service.ListProductsRequest(request) @@ -375,7 +383,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -389,8 +397,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = product_search_service.ListReferenceImagesRequest(request) @@ -451,7 +461,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. @@ -465,8 +475,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 = product_search_service.ListReferenceImagesRequest(request) @@ -531,7 +543,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -545,8 +557,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = product_search_service.ListProductsInProductSetRequest(request) @@ -609,7 +623,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. @@ -623,8 +637,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 = product_search_service.ListProductsInProductSetRequest(request) diff --git a/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/transports/grpc.py b/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/transports/grpc.py index b96d939d95db..84b7d7b314f9 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/transports/grpc.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/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.vision_v1.types import product_search_service from .base import DEFAULT_CLIENT_INFO, ProductSearchTransport +try: + from google.api_core import client_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.vision.v1.ProductSearch", + "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.vision.v1.ProductSearch", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProductSearchGrpcTransport(ProductSearchTransport): """gRPC backend transport for ProductSearch. @@ -199,7 +280,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 @@ -263,7 +349,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 @@ -295,7 +383,7 @@ def create_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product_set" not in self._stubs: - self._stubs["create_product_set"] = self.grpc_channel.unary_unary( + self._stubs["create_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/CreateProductSet", request_serializer=product_search_service.CreateProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -329,7 +417,7 @@ def list_product_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_product_sets" not in self._stubs: - self._stubs["list_product_sets"] = self.grpc_channel.unary_unary( + self._stubs["list_product_sets"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/ListProductSets", request_serializer=product_search_service.ListProductSetsRequest.serialize, response_deserializer=product_search_service.ListProductSetsResponse.deserialize, @@ -361,7 +449,7 @@ def get_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product_set" not in self._stubs: - self._stubs["get_product_set"] = self.grpc_channel.unary_unary( + self._stubs["get_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/GetProductSet", request_serializer=product_search_service.GetProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -398,7 +486,7 @@ def update_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product_set" not in self._stubs: - self._stubs["update_product_set"] = self.grpc_channel.unary_unary( + self._stubs["update_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/UpdateProductSet", request_serializer=product_search_service.UpdateProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -428,7 +516,7 @@ def delete_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product_set" not in self._stubs: - self._stubs["delete_product_set"] = self.grpc_channel.unary_unary( + self._stubs["delete_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/DeleteProductSet", request_serializer=product_search_service.DeleteProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -465,7 +553,7 @@ def create_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product" not in self._stubs: - self._stubs["create_product"] = self.grpc_channel.unary_unary( + self._stubs["create_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/CreateProduct", request_serializer=product_search_service.CreateProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -499,7 +587,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.cloud.vision.v1.ProductSearch/ListProducts", request_serializer=product_search_service.ListProductsRequest.serialize, response_deserializer=product_search_service.ListProductsResponse.deserialize, @@ -531,7 +619,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.cloud.vision.v1.ProductSearch/GetProduct", request_serializer=product_search_service.GetProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -574,7 +662,7 @@ def update_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product" not in self._stubs: - self._stubs["update_product"] = self.grpc_channel.unary_unary( + self._stubs["update_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/UpdateProduct", request_serializer=product_search_service.UpdateProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -605,7 +693,7 @@ def delete_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product" not in self._stubs: - self._stubs["delete_product"] = self.grpc_channel.unary_unary( + self._stubs["delete_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/DeleteProduct", request_serializer=product_search_service.DeleteProductRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -655,7 +743,7 @@ def create_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_reference_image" not in self._stubs: - self._stubs["create_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["create_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/CreateReferenceImage", request_serializer=product_search_service.CreateReferenceImageRequest.serialize, response_deserializer=product_search_service.ReferenceImage.deserialize, @@ -690,7 +778,7 @@ def delete_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_reference_image" not in self._stubs: - self._stubs["delete_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["delete_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/DeleteReferenceImage", request_serializer=product_search_service.DeleteReferenceImageRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -725,7 +813,7 @@ def list_reference_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_reference_images" not in self._stubs: - self._stubs["list_reference_images"] = self.grpc_channel.unary_unary( + self._stubs["list_reference_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/ListReferenceImages", request_serializer=product_search_service.ListReferenceImagesRequest.serialize, response_deserializer=product_search_service.ListReferenceImagesResponse.deserialize, @@ -758,7 +846,7 @@ def get_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_reference_image" not in self._stubs: - self._stubs["get_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["get_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/GetReferenceImage", request_serializer=product_search_service.GetReferenceImageRequest.serialize, response_deserializer=product_search_service.ReferenceImage.deserialize, @@ -794,7 +882,9 @@ def add_product_to_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_product_to_product_set" not in self._stubs: - self._stubs["add_product_to_product_set"] = self.grpc_channel.unary_unary( + self._stubs[ + "add_product_to_product_set" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/AddProductToProductSet", request_serializer=product_search_service.AddProductToProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -825,7 +915,7 @@ def remove_product_from_product_set( if "remove_product_from_product_set" not in self._stubs: self._stubs[ "remove_product_from_product_set" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/RemoveProductFromProductSet", request_serializer=product_search_service.RemoveProductFromProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -861,7 +951,9 @@ def list_products_in_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products_in_product_set" not in self._stubs: - self._stubs["list_products_in_product_set"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_products_in_product_set" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/ListProductsInProductSet", request_serializer=product_search_service.ListProductsInProductSetRequest.serialize, response_deserializer=product_search_service.ListProductsInProductSetResponse.deserialize, @@ -900,7 +992,7 @@ def import_product_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_product_sets" not in self._stubs: - self._stubs["import_product_sets"] = self.grpc_channel.unary_unary( + self._stubs["import_product_sets"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/ImportProductSets", request_serializer=product_search_service.ImportProductSetsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -954,7 +1046,7 @@ def purge_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_products" not in self._stubs: - self._stubs["purge_products"] = self.grpc_channel.unary_unary( + self._stubs["purge_products"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/PurgeProducts", request_serializer=product_search_service.PurgeProductsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -962,7 +1054,7 @@ def purge_products( return self._stubs["purge_products"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -974,7 +1066,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-cloud-vision/google/cloud/vision_v1/services/product_search/transports/grpc_asyncio.py b/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/transports/grpc_asyncio.py index 8cf21332e609..3cb26f4ff0a2 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/transports/grpc_asyncio.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/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.vision_v1.types import product_search_service from .base import DEFAULT_CLIENT_INFO, ProductSearchTransport from .grpc import ProductSearchGrpcTransport +try: + from google.api_core import client_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.vision.v1.ProductSearch", + "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.vision.v1.ProductSearch", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProductSearchGrpcAsyncIOTransport(ProductSearchTransport): """gRPC AsyncIO backend transport for ProductSearch. @@ -246,10 +328,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 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 create_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product_set" not in self._stubs: - self._stubs["create_product_set"] = self.grpc_channel.unary_unary( + self._stubs["create_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/CreateProductSet", request_serializer=product_search_service.CreateProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -339,7 +424,7 @@ def list_product_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_product_sets" not in self._stubs: - self._stubs["list_product_sets"] = self.grpc_channel.unary_unary( + self._stubs["list_product_sets"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/ListProductSets", request_serializer=product_search_service.ListProductSetsRequest.serialize, response_deserializer=product_search_service.ListProductSetsResponse.deserialize, @@ -372,7 +457,7 @@ def get_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product_set" not in self._stubs: - self._stubs["get_product_set"] = self.grpc_channel.unary_unary( + self._stubs["get_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/GetProductSet", request_serializer=product_search_service.GetProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -409,7 +494,7 @@ def update_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product_set" not in self._stubs: - self._stubs["update_product_set"] = self.grpc_channel.unary_unary( + self._stubs["update_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/UpdateProductSet", request_serializer=product_search_service.UpdateProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -441,7 +526,7 @@ def delete_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product_set" not in self._stubs: - self._stubs["delete_product_set"] = self.grpc_channel.unary_unary( + self._stubs["delete_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/DeleteProductSet", request_serializer=product_search_service.DeleteProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -479,7 +564,7 @@ def create_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product" not in self._stubs: - self._stubs["create_product"] = self.grpc_channel.unary_unary( + self._stubs["create_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/CreateProduct", request_serializer=product_search_service.CreateProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -513,7 +598,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.cloud.vision.v1.ProductSearch/ListProducts", request_serializer=product_search_service.ListProductsRequest.serialize, response_deserializer=product_search_service.ListProductsResponse.deserialize, @@ -546,7 +631,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.cloud.vision.v1.ProductSearch/GetProduct", request_serializer=product_search_service.GetProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -590,7 +675,7 @@ def update_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product" not in self._stubs: - self._stubs["update_product"] = self.grpc_channel.unary_unary( + self._stubs["update_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/UpdateProduct", request_serializer=product_search_service.UpdateProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -623,7 +708,7 @@ def delete_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product" not in self._stubs: - self._stubs["delete_product"] = self.grpc_channel.unary_unary( + self._stubs["delete_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/DeleteProduct", request_serializer=product_search_service.DeleteProductRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -673,7 +758,7 @@ def create_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_reference_image" not in self._stubs: - self._stubs["create_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["create_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/CreateReferenceImage", request_serializer=product_search_service.CreateReferenceImageRequest.serialize, response_deserializer=product_search_service.ReferenceImage.deserialize, @@ -708,7 +793,7 @@ def delete_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_reference_image" not in self._stubs: - self._stubs["delete_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["delete_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/DeleteReferenceImage", request_serializer=product_search_service.DeleteReferenceImageRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -743,7 +828,7 @@ def list_reference_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_reference_images" not in self._stubs: - self._stubs["list_reference_images"] = self.grpc_channel.unary_unary( + self._stubs["list_reference_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/ListReferenceImages", request_serializer=product_search_service.ListReferenceImagesRequest.serialize, response_deserializer=product_search_service.ListReferenceImagesResponse.deserialize, @@ -776,7 +861,7 @@ def get_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_reference_image" not in self._stubs: - self._stubs["get_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["get_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/GetReferenceImage", request_serializer=product_search_service.GetReferenceImageRequest.serialize, response_deserializer=product_search_service.ReferenceImage.deserialize, @@ -813,7 +898,9 @@ def add_product_to_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_product_to_product_set" not in self._stubs: - self._stubs["add_product_to_product_set"] = self.grpc_channel.unary_unary( + self._stubs[ + "add_product_to_product_set" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/AddProductToProductSet", request_serializer=product_search_service.AddProductToProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -845,7 +932,7 @@ def remove_product_from_product_set( if "remove_product_from_product_set" not in self._stubs: self._stubs[ "remove_product_from_product_set" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/RemoveProductFromProductSet", request_serializer=product_search_service.RemoveProductFromProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -881,7 +968,9 @@ def list_products_in_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products_in_product_set" not in self._stubs: - self._stubs["list_products_in_product_set"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_products_in_product_set" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/ListProductsInProductSet", request_serializer=product_search_service.ListProductsInProductSetRequest.serialize, response_deserializer=product_search_service.ListProductsInProductSetResponse.deserialize, @@ -921,7 +1010,7 @@ def import_product_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_product_sets" not in self._stubs: - self._stubs["import_product_sets"] = self.grpc_channel.unary_unary( + self._stubs["import_product_sets"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/ImportProductSets", request_serializer=product_search_service.ImportProductSetsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -976,7 +1065,7 @@ def purge_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_products" not in self._stubs: - self._stubs["purge_products"] = self.grpc_channel.unary_unary( + self._stubs["purge_products"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/PurgeProducts", request_serializer=product_search_service.PurgeProductsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1269,7 +1358,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: @@ -1285,7 +1374,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-cloud-vision/google/cloud/vision_v1/services/product_search/transports/rest.py b/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/transports/rest.py index a2d580b8b90b..743384dbd371 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/transports/rest.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/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, @@ -203,9 +211,10 @@ def post_update_product_set(self, response): def pre_add_product_to_product_set( self, request: product_search_service.AddProductToProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.AddProductToProductSetRequest, Sequence[Tuple[str, str]] + product_search_service.AddProductToProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for add_product_to_product_set @@ -217,8 +226,11 @@ def pre_add_product_to_product_set( def pre_create_product( self, request: product_search_service.CreateProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.CreateProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.CreateProductRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_product Override in a subclass to manipulate the request or metadata @@ -240,9 +252,10 @@ def post_create_product( def pre_create_product_set( self, request: product_search_service.CreateProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.CreateProductSetRequest, Sequence[Tuple[str, str]] + product_search_service.CreateProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_product_set @@ -265,9 +278,10 @@ def post_create_product_set( def pre_create_reference_image( self, request: product_search_service.CreateReferenceImageRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.CreateReferenceImageRequest, Sequence[Tuple[str, str]] + product_search_service.CreateReferenceImageRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_reference_image @@ -290,8 +304,11 @@ def post_create_reference_image( def pre_delete_product( self, request: product_search_service.DeleteProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.DeleteProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.DeleteProductRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_product Override in a subclass to manipulate the request or metadata @@ -302,9 +319,10 @@ def pre_delete_product( def pre_delete_product_set( self, request: product_search_service.DeleteProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.DeleteProductSetRequest, Sequence[Tuple[str, str]] + product_search_service.DeleteProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_product_set @@ -316,9 +334,10 @@ def pre_delete_product_set( def pre_delete_reference_image( self, request: product_search_service.DeleteReferenceImageRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.DeleteReferenceImageRequest, Sequence[Tuple[str, str]] + product_search_service.DeleteReferenceImageRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_reference_image @@ -330,8 +349,11 @@ def pre_delete_reference_image( def pre_get_product( self, request: product_search_service.GetProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.GetProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.GetProductRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_product Override in a subclass to manipulate the request or metadata @@ -353,8 +375,11 @@ def post_get_product( def pre_get_product_set( self, request: product_search_service.GetProductSetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.GetProductSetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.GetProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_product_set Override in a subclass to manipulate the request or metadata @@ -376,9 +401,10 @@ def post_get_product_set( def pre_get_reference_image( self, request: product_search_service.GetReferenceImageRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.GetReferenceImageRequest, Sequence[Tuple[str, str]] + product_search_service.GetReferenceImageRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_reference_image @@ -401,9 +427,10 @@ def post_get_reference_image( def pre_import_product_sets( self, request: product_search_service.ImportProductSetsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.ImportProductSetsRequest, Sequence[Tuple[str, str]] + product_search_service.ImportProductSetsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for import_product_sets @@ -426,8 +453,11 @@ def post_import_product_sets( def pre_list_products( self, request: product_search_service.ListProductsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.ListProductsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.ListProductsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_products Override in a subclass to manipulate the request or metadata @@ -449,9 +479,10 @@ def post_list_products( def pre_list_product_sets( self, request: product_search_service.ListProductSetsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.ListProductSetsRequest, Sequence[Tuple[str, str]] + product_search_service.ListProductSetsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_product_sets @@ -474,10 +505,10 @@ def post_list_product_sets( def pre_list_products_in_product_set( self, request: product_search_service.ListProductsInProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ product_search_service.ListProductsInProductSetRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_products_in_product_set @@ -500,9 +531,10 @@ def post_list_products_in_product_set( def pre_list_reference_images( self, request: product_search_service.ListReferenceImagesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.ListReferenceImagesRequest, Sequence[Tuple[str, str]] + product_search_service.ListReferenceImagesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_reference_images @@ -525,8 +557,11 @@ def post_list_reference_images( def pre_purge_products( self, request: product_search_service.PurgeProductsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.PurgeProductsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.PurgeProductsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for purge_products Override in a subclass to manipulate the request or metadata @@ -548,10 +583,10 @@ def post_purge_products( def pre_remove_product_from_product_set( self, request: product_search_service.RemoveProductFromProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ product_search_service.RemoveProductFromProductSetRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for remove_product_from_product_set @@ -563,8 +598,11 @@ def pre_remove_product_from_product_set( def pre_update_product( self, request: product_search_service.UpdateProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.UpdateProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.UpdateProductRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_product Override in a subclass to manipulate the request or metadata @@ -586,9 +624,10 @@ def post_update_product( def pre_update_product_set( self, request: product_search_service.UpdateProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.UpdateProductSetRequest, Sequence[Tuple[str, str]] + product_search_service.UpdateProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_product_set @@ -611,8 +650,10 @@ def post_update_product_set( 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 @@ -818,7 +859,7 @@ 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 add product to product set method over HTTP. @@ -830,13 +871,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 = ( _BaseProductSearchRestTransport._BaseAddProductToProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_add_product_to_product_set( request, metadata ) @@ -853,6 +897,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1.ProductSearchClient.AddProductToProductSet", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "AddProductToProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._AddProductToProductSet._get_response( self._host, @@ -904,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]]] = (), ) -> product_search_service.Product: r"""Call the create product method over HTTP. @@ -914,8 +985,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.product_search_service.Product: @@ -925,6 +998,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseCreateProduct._get_http_options() ) + request, metadata = self._interceptor.pre_create_product(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseCreateProduct._get_transcoded_request( http_options, request @@ -939,6 +1013,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1.ProductSearchClient.CreateProduct", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "CreateProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._CreateProduct._get_response( self._host, @@ -960,7 +1061,29 @@ def __call__( pb_resp = product_search_service.Product.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.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.cloud.vision_v1.ProductSearchClient.create_product", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "CreateProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateProductSet( @@ -998,7 +1121,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Call the create product set method over HTTP. @@ -1008,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: ~.product_search_service.ProductSet: @@ -1024,6 +1149,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseCreateProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_create_product_set( request, metadata ) @@ -1040,6 +1166,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1.ProductSearchClient.CreateProductSet", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "CreateProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._CreateProductSet._get_response( self._host, @@ -1061,7 +1214,31 @@ def __call__( pb_resp = product_search_service.ProductSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_product_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ProductSet.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1.ProductSearchClient.create_product_set", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "CreateProductSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateReferenceImage( @@ -1099,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]]] = (), ) -> product_search_service.ReferenceImage: r"""Call the create reference image method over HTTP. @@ -1109,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: ~.product_search_service.ReferenceImage: @@ -1122,6 +1301,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseCreateReferenceImage._get_http_options() ) + request, metadata = self._interceptor.pre_create_reference_image( request, metadata ) @@ -1138,6 +1318,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1.ProductSearchClient.CreateReferenceImage", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "CreateReferenceImage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._CreateReferenceImage._get_response( self._host, @@ -1159,7 +1366,31 @@ def __call__( pb_resp = product_search_service.ReferenceImage.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_reference_image(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ReferenceImage.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1.ProductSearchClient.create_reference_image", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "CreateReferenceImage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteProduct( @@ -1196,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]]] = (), ): r"""Call the delete product method over HTTP. @@ -1206,13 +1437,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 = ( _BaseProductSearchRestTransport._BaseDeleteProduct._get_http_options() ) + request, metadata = self._interceptor.pre_delete_product(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseDeleteProduct._get_transcoded_request( http_options, request @@ -1223,6 +1457,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1.ProductSearchClient.DeleteProduct", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "DeleteProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._DeleteProduct._get_response( self._host, @@ -1272,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]]] = (), ): r"""Call the delete product set method over HTTP. @@ -1282,13 +1543,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 = ( _BaseProductSearchRestTransport._BaseDeleteProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_delete_product_set( request, metadata ) @@ -1301,6 +1565,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1.ProductSearchClient.DeleteProductSet", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "DeleteProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._DeleteProductSet._get_response( self._host, @@ -1350,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]]] = (), ): r"""Call the delete reference image method over HTTP. @@ -1360,13 +1651,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 = ( _BaseProductSearchRestTransport._BaseDeleteReferenceImage._get_http_options() ) + request, metadata = self._interceptor.pre_delete_reference_image( request, metadata ) @@ -1379,6 +1673,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1.ProductSearchClient.DeleteReferenceImage", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "DeleteReferenceImage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._DeleteReferenceImage._get_response( self._host, @@ -1428,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]]] = (), ) -> product_search_service.Product: r"""Call the get product method over HTTP. @@ -1438,8 +1759,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.product_search_service.Product: @@ -1449,6 +1772,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseGetProduct._get_http_options() ) + request, metadata = self._interceptor.pre_get_product(request, metadata) transcoded_request = ( _BaseProductSearchRestTransport._BaseGetProduct._get_transcoded_request( @@ -1463,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.vision_v1.ProductSearchClient.GetProduct", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "GetProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._GetProduct._get_response( self._host, @@ -1483,7 +1834,29 @@ def __call__( pb_resp = product_search_service.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 = product_search_service.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.cloud.vision_v1.ProductSearchClient.get_product", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "GetProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetProductSet( @@ -1520,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]]] = (), ) -> product_search_service.ProductSet: r"""Call the get product set method over HTTP. @@ -1530,8 +1903,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.product_search_service.ProductSet: @@ -1546,6 +1921,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseGetProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_get_product_set(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseGetProductSet._get_transcoded_request( http_options, request @@ -1556,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.vision_v1.ProductSearchClient.GetProductSet", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "GetProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._GetProductSet._get_response( self._host, @@ -1576,7 +1979,31 @@ def __call__( pb_resp = product_search_service.ProductSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_product_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ProductSet.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1.ProductSearchClient.get_product_set", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "GetProductSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetReferenceImage( @@ -1613,7 +2040,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Call the get reference image method over HTTP. @@ -1623,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: ~.product_search_service.ReferenceImage: @@ -1636,6 +2065,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseGetReferenceImage._get_http_options() ) + request, metadata = self._interceptor.pre_get_reference_image( request, metadata ) @@ -1648,6 +2078,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1.ProductSearchClient.GetReferenceImage", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "GetReferenceImage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._GetReferenceImage._get_response( self._host, @@ -1668,7 +2125,31 @@ def __call__( pb_resp = product_search_service.ReferenceImage.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_reference_image(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ReferenceImage.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1.ProductSearchClient.get_reference_image", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "GetReferenceImage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportProductSets( @@ -1706,7 +2187,7 @@ 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 product sets method over HTTP. @@ -1716,8 +2197,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1730,6 +2213,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseImportProductSets._get_http_options() ) + request, metadata = self._interceptor.pre_import_product_sets( request, metadata ) @@ -1746,6 +2230,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1.ProductSearchClient.ImportProductSets", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "ImportProductSets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._ImportProductSets._get_response( self._host, @@ -1765,7 +2276,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_product_sets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1.ProductSearchClient.import_product_sets", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "ImportProductSets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProducts( @@ -1802,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]]] = (), ) -> product_search_service.ListProductsResponse: r"""Call the list products method over HTTP. @@ -1812,8 +2345,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.product_search_service.ListProductsResponse: @@ -1823,6 +2358,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseListProducts._get_http_options() ) + request, metadata = self._interceptor.pre_list_products(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseListProducts._get_transcoded_request( http_options, request @@ -1833,6 +2369,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1.ProductSearchClient.ListProducts", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "ListProducts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._ListProducts._get_response( self._host, @@ -1853,7 +2416,31 @@ def __call__( pb_resp = product_search_service.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 = ( + product_search_service.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.cloud.vision_v1.ProductSearchClient.list_products", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "ListProducts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProductSets( @@ -1890,7 +2477,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ListProductSetsResponse: r"""Call the list product sets method over HTTP. @@ -1900,8 +2487,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.product_search_service.ListProductSetsResponse: @@ -1911,6 +2500,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseListProductSets._get_http_options() ) + request, metadata = self._interceptor.pre_list_product_sets( request, metadata ) @@ -1923,6 +2513,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1.ProductSearchClient.ListProductSets", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "ListProductSets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._ListProductSets._get_response( self._host, @@ -1943,7 +2560,31 @@ def __call__( pb_resp = product_search_service.ListProductSetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_product_sets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + product_search_service.ListProductSetsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1.ProductSearchClient.list_product_sets", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "ListProductSets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProductsInProductSet( @@ -1981,7 +2622,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ListProductsInProductSetResponse: r"""Call the list products in product set method over HTTP. @@ -1993,8 +2634,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.product_search_service.ListProductsInProductSetResponse: @@ -2006,6 +2649,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseListProductsInProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_list_products_in_product_set( request, metadata ) @@ -2018,6 +2662,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1.ProductSearchClient.ListProductsInProductSet", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "ListProductsInProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ProductSearchRestTransport._ListProductsInProductSet._get_response( @@ -2040,7 +2711,33 @@ def __call__( pb_resp = product_search_service.ListProductsInProductSetResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_products_in_product_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + product_search_service.ListProductsInProductSetResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1.ProductSearchClient.list_products_in_product_set", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "ListProductsInProductSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListReferenceImages( @@ -2077,7 +2774,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ListReferenceImagesResponse: r"""Call the list reference images method over HTTP. @@ -2087,8 +2784,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.product_search_service.ListReferenceImagesResponse: @@ -2098,6 +2797,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseListReferenceImages._get_http_options() ) + request, metadata = self._interceptor.pre_list_reference_images( request, metadata ) @@ -2110,6 +2810,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1.ProductSearchClient.ListReferenceImages", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "ListReferenceImages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._ListReferenceImages._get_response( self._host, @@ -2130,7 +2857,33 @@ def __call__( pb_resp = product_search_service.ListReferenceImagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_reference_images(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + product_search_service.ListReferenceImagesResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1.ProductSearchClient.list_reference_images", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "ListReferenceImages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PurgeProducts( @@ -2168,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]]] = (), ) -> operations_pb2.Operation: r"""Call the purge products method over HTTP. @@ -2178,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: ~.operations_pb2.Operation: @@ -2192,6 +2947,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BasePurgeProducts._get_http_options() ) + request, metadata = self._interceptor.pre_purge_products(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BasePurgeProducts._get_transcoded_request( http_options, request @@ -2206,6 +2962,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1.ProductSearchClient.PurgeProducts", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "PurgeProducts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._PurgeProducts._get_response( self._host, @@ -2225,7 +3008,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_purge_products(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1.ProductSearchClient.purge_products", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "PurgeProducts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveProductFromProductSet( @@ -2264,7 +3069,7 @@ 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 remove product from product set method over HTTP. @@ -2276,13 +3081,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 = ( _BaseProductSearchRestTransport._BaseRemoveProductFromProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_remove_product_from_product_set( request, metadata ) @@ -2299,6 +3107,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1.ProductSearchClient.RemoveProductFromProductSet", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "RemoveProductFromProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ProductSearchRestTransport._RemoveProductFromProductSet._get_response( @@ -2352,7 +3187,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Call the update product method over HTTP. @@ -2362,8 +3197,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.product_search_service.Product: @@ -2373,6 +3210,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseUpdateProduct._get_http_options() ) + request, metadata = self._interceptor.pre_update_product(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseUpdateProduct._get_transcoded_request( http_options, request @@ -2387,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.cloud.vision_v1.ProductSearchClient.UpdateProduct", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "UpdateProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._UpdateProduct._get_response( self._host, @@ -2408,7 +3273,29 @@ def __call__( pb_resp = product_search_service.Product.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.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.cloud.vision_v1.ProductSearchClient.update_product", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "UpdateProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateProductSet( @@ -2446,7 +3333,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Call the update product set method over HTTP. @@ -2456,8 +3343,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.product_search_service.ProductSet: @@ -2472,6 +3361,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseUpdateProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_update_product_set( request, metadata ) @@ -2488,6 +3378,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1.ProductSearchClient.UpdateProductSet", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "UpdateProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._UpdateProductSet._get_response( self._host, @@ -2509,7 +3426,31 @@ def __call__( pb_resp = product_search_service.ProductSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_product_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ProductSet.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1.ProductSearchClient.update_product_set", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "UpdateProductSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -2744,7 +3685,7 @@ 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. @@ -2754,8 +3695,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -2764,6 +3707,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -2774,6 +3718,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1.ProductSearchClient.GetOperation", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._GetOperation._get_response( self._host, @@ -2793,6 +3764,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.vision_v1.ProductSearchAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/gapic_version.py b/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/gapic_version.py index e194ca38362b..558c8aab67c5 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/gapic_version.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.8.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/async_client.py b/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/async_client.py index 42b13364b0f1..3e7fecb23cee 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/async_client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/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, @@ -48,6 +49,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport from .transports.grpc_asyncio import ImageAnnotatorGrpcAsyncIOTransport +try: + from google.api_core import client_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 ImageAnnotatorAsyncClient: """Service that performs Google Cloud Vision API detection tasks @@ -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.vision_v1p1beta1.ImageAnnotatorAsyncClient`.", + extra={ + "serviceName": "google.cloud.vision.v1p1beta1.ImageAnnotator", + "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.vision.v1p1beta1.ImageAnnotator", + "credentialsType": None, + }, + ) + async def batch_annotate_images( self, request: Optional[ @@ -266,7 +298,7 @@ async def batch_annotate_images( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Run image detection and annotation for a batch of images. @@ -310,8 +342,10 @@ async def sample_batch_annotate_images(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p1beta1.types.BatchAnnotateImagesResponse: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/client.py b/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/client.py index 81cb6c0891a7..a5722d3edd77 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/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.vision_v1p1beta1.types import image_annotator from .transports.base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport @@ -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.vision_v1p1beta1.ImageAnnotatorClient`.", + extra={ + "serviceName": "google.cloud.vision.v1p1beta1.ImageAnnotator", + "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.vision.v1p1beta1.ImageAnnotator", + "credentialsType": None, + }, + ) + def batch_annotate_images( self, request: Optional[ @@ -635,7 +672,7 @@ def batch_annotate_images( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Run image detection and annotation for a batch of images. @@ -679,8 +716,10 @@ def sample_batch_annotate_images(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p1beta1.types.BatchAnnotateImagesResponse: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc.py b/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc.py index 590b6b7f8042..ad00804e3880 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/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.cloud.vision_v1p1beta1.types import image_annotator from .base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport +try: + from google.api_core import client_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.vision.v1p1beta1.ImageAnnotator", + "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.vision.v1p1beta1.ImageAnnotator", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ImageAnnotatorGrpcTransport(ImageAnnotatorTransport): """gRPC backend transport for ImageAnnotator. @@ -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 @@ -260,7 +346,7 @@ def batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_images" not in self._stubs: - self._stubs["batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p1beta1.ImageAnnotator/BatchAnnotateImages", request_serializer=image_annotator.BatchAnnotateImagesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateImagesResponse.deserialize, @@ -268,7 +354,7 @@ def batch_annotate_images( return self._stubs["batch_annotate_images"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc_asyncio.py b/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc_asyncio.py index 25580ea2d0a1..0391fb740c62 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc_asyncio.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/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.cloud.vision_v1p1beta1.types import image_annotator from .base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport from .grpc import ImageAnnotatorGrpcTransport +try: + from google.api_core import client_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.vision.v1p1beta1.ImageAnnotator", + "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.vision.v1p1beta1.ImageAnnotator", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ImageAnnotatorGrpcAsyncIOTransport(ImageAnnotatorTransport): """gRPC AsyncIO backend transport for ImageAnnotator. @@ -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 @@ -268,7 +353,7 @@ def batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_images" not in self._stubs: - self._stubs["batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p1beta1.ImageAnnotator/BatchAnnotateImages", request_serializer=image_annotator.BatchAnnotateImagesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateImagesResponse.deserialize, @@ -301,7 +386,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-vision/google/cloud/vision_v1p1beta1/services/image_annotator/transports/rest.py b/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/transports/rest.py index edfcce45ff5e..3b0bd72d46c7 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/transports/rest.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/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,11 @@ def post_batch_annotate_images(self, response): def pre_batch_annotate_images( self, request: image_annotator.BatchAnnotateImagesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[image_annotator.BatchAnnotateImagesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + image_annotator.BatchAnnotateImagesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_annotate_images Override in a subclass to manipulate the request or metadata @@ -223,7 +234,7 @@ 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_annotator.BatchAnnotateImagesResponse: r"""Call the batch annotate images method over HTTP. @@ -234,8 +245,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_annotator.BatchAnnotateImagesResponse: @@ -247,6 +260,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseBatchAnnotateImages._get_http_options() ) + request, metadata = self._interceptor.pre_batch_annotate_images( request, metadata ) @@ -263,6 +277,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p1beta1.ImageAnnotatorClient.BatchAnnotateImages", + extra={ + "serviceName": "google.cloud.vision.v1p1beta1.ImageAnnotator", + "rpcName": "BatchAnnotateImages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImageAnnotatorRestTransport._BatchAnnotateImages._get_response( self._host, @@ -284,7 +325,31 @@ def __call__( pb_resp = image_annotator.BatchAnnotateImagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_annotate_images(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + image_annotator.BatchAnnotateImagesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p1beta1.ImageAnnotatorClient.batch_annotate_images", + extra={ + "serviceName": "google.cloud.vision.v1p1beta1.ImageAnnotator", + "rpcName": "BatchAnnotateImages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/gapic_version.py b/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/gapic_version.py index e194ca38362b..558c8aab67c5 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/gapic_version.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.8.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/async_client.py b/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/async_client.py index e04a295b0b33..1d2cdf892ec1 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/async_client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/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, ImageAnnotatorTransport from .transports.grpc_asyncio import ImageAnnotatorGrpcAsyncIOTransport +try: + from google.api_core import client_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 ImageAnnotatorAsyncClient: """Service that performs Google Cloud Vision API detection tasks @@ -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.vision_v1p2beta1.ImageAnnotatorAsyncClient`.", + extra={ + "serviceName": "google.cloud.vision.v1p2beta1.ImageAnnotator", + "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.vision.v1p2beta1.ImageAnnotator", + "credentialsType": None, + }, + ) + async def batch_annotate_images( self, request: Optional[ @@ -269,7 +301,7 @@ async def batch_annotate_images( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Run image detection and annotation for a batch of images. @@ -313,8 +345,10 @@ async def sample_batch_annotate_images(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p2beta1.types.BatchAnnotateImagesResponse: @@ -373,7 +407,7 @@ async def async_batch_annotate_files( ] = None, retry: OptionalRetry = gapic_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"""Run async image detection and annotation for a list of generic files (e.g. PDF) which may contain multiple pages and multiple @@ -427,8 +461,10 @@ async def sample_async_batch_annotate_files(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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-vision/google/cloud/vision_v1p2beta1/services/image_annotator/client.py b/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/client.py index 93667ce3afb3..6aad5eff1b1f 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/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 @@ -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( @@ -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.vision_v1p2beta1.ImageAnnotatorClient`.", + extra={ + "serviceName": "google.cloud.vision.v1p2beta1.ImageAnnotator", + "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.vision.v1p2beta1.ImageAnnotator", + "credentialsType": None, + }, + ) + def batch_annotate_images( self, request: Optional[ @@ -638,7 +675,7 @@ def batch_annotate_images( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Run image detection and annotation for a batch of images. @@ -682,8 +719,10 @@ def sample_batch_annotate_images(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p2beta1.types.BatchAnnotateImagesResponse: @@ -739,7 +778,7 @@ def async_batch_annotate_files( ] = None, retry: OptionalRetry = gapic_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"""Run async image detection and annotation for a list of generic files (e.g. PDF) which may contain multiple pages and multiple @@ -793,8 +832,10 @@ def sample_async_batch_annotate_files(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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-vision/google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc.py b/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc.py index ebbfce76c6aa..10fc99a14455 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/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.vision_v1p2beta1.types import image_annotator from .base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport +try: + from google.api_core import client_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.vision.v1p2beta1.ImageAnnotator", + "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.vision.v1p2beta1.ImageAnnotator", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ImageAnnotatorGrpcTransport(ImageAnnotatorTransport): """gRPC backend transport for ImageAnnotator. @@ -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 @@ -276,7 +364,7 @@ def batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_images" not in self._stubs: - self._stubs["batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p2beta1.ImageAnnotator/BatchAnnotateImages", request_serializer=image_annotator.BatchAnnotateImagesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateImagesResponse.deserialize, @@ -310,7 +398,9 @@ def async_batch_annotate_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "async_batch_annotate_files" not in self._stubs: - self._stubs["async_batch_annotate_files"] = self.grpc_channel.unary_unary( + self._stubs[ + "async_batch_annotate_files" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p2beta1.ImageAnnotator/AsyncBatchAnnotateFiles", request_serializer=image_annotator.AsyncBatchAnnotateFilesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -318,7 +408,7 @@ def async_batch_annotate_files( return self._stubs["async_batch_annotate_files"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc_asyncio.py b/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc_asyncio.py index 9ae33f599295..1ec4b8b92929 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc_asyncio.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/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.vision_v1p2beta1.types import image_annotator from .base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport from .grpc import ImageAnnotatorGrpcTransport +try: + from google.api_core import client_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.vision.v1p2beta1.ImageAnnotator", + "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.vision.v1p2beta1.ImageAnnotator", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ImageAnnotatorGrpcAsyncIOTransport(ImageAnnotatorTransport): """gRPC AsyncIO backend transport for ImageAnnotator. @@ -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. @@ -286,7 +371,7 @@ def batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_images" not in self._stubs: - self._stubs["batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p2beta1.ImageAnnotator/BatchAnnotateImages", request_serializer=image_annotator.BatchAnnotateImagesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateImagesResponse.deserialize, @@ -321,7 +406,9 @@ def async_batch_annotate_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "async_batch_annotate_files" not in self._stubs: - self._stubs["async_batch_annotate_files"] = self.grpc_channel.unary_unary( + self._stubs[ + "async_batch_annotate_files" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p2beta1.ImageAnnotator/AsyncBatchAnnotateFiles", request_serializer=image_annotator.AsyncBatchAnnotateFilesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -369,7 +456,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-vision/google/cloud/vision_v1p2beta1/services/image_annotator/transports/rest.py b/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/transports/rest.py index c7fede3ba805..6787e920ee4f 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/transports/rest.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/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,9 +94,10 @@ def post_batch_annotate_images(self, response): def pre_async_batch_annotate_files( self, request: image_annotator.AsyncBatchAnnotateFilesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - image_annotator.AsyncBatchAnnotateFilesRequest, Sequence[Tuple[str, str]] + image_annotator.AsyncBatchAnnotateFilesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for async_batch_annotate_files @@ -111,8 +120,11 @@ def post_async_batch_annotate_files( def pre_batch_annotate_images( self, request: image_annotator.BatchAnnotateImagesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[image_annotator.BatchAnnotateImagesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + image_annotator.BatchAnnotateImagesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_annotate_images Override in a subclass to manipulate the request or metadata @@ -285,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]]] = (), ) -> operations_pb2.Operation: r"""Call the async batch annotate files method over HTTP. @@ -298,8 +310,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -312,6 +326,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseAsyncBatchAnnotateFiles._get_http_options() ) + request, metadata = self._interceptor.pre_async_batch_annotate_files( request, metadata ) @@ -328,6 +343,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p2beta1.ImageAnnotatorClient.AsyncBatchAnnotateFiles", + extra={ + "serviceName": "google.cloud.vision.v1p2beta1.ImageAnnotator", + "rpcName": "AsyncBatchAnnotateFiles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ImageAnnotatorRestTransport._AsyncBatchAnnotateFiles._get_response( @@ -349,7 +391,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_async_batch_annotate_files(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p2beta1.ImageAnnotatorClient.async_batch_annotate_files", + extra={ + "serviceName": "google.cloud.vision.v1p2beta1.ImageAnnotator", + "rpcName": "AsyncBatchAnnotateFiles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchAnnotateImages( @@ -388,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]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Call the batch annotate images method over HTTP. @@ -399,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: ~.image_annotator.BatchAnnotateImagesResponse: @@ -412,6 +478,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseBatchAnnotateImages._get_http_options() ) + request, metadata = self._interceptor.pre_batch_annotate_images( request, metadata ) @@ -428,6 +495,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p2beta1.ImageAnnotatorClient.BatchAnnotateImages", + extra={ + "serviceName": "google.cloud.vision.v1p2beta1.ImageAnnotator", + "rpcName": "BatchAnnotateImages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImageAnnotatorRestTransport._BatchAnnotateImages._get_response( self._host, @@ -449,7 +543,31 @@ def __call__( pb_resp = image_annotator.BatchAnnotateImagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_annotate_images(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + image_annotator.BatchAnnotateImagesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p2beta1.ImageAnnotatorClient.batch_annotate_images", + extra={ + "serviceName": "google.cloud.vision.v1p2beta1.ImageAnnotator", + "rpcName": "BatchAnnotateImages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/gapic_version.py b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/gapic_version.py index e194ca38362b..558c8aab67c5 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/gapic_version.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.8.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/async_client.py b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/async_client.py index a3f1d2d20e4d..a1b4562e1d75 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/async_client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/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, ImageAnnotatorTransport from .transports.grpc_asyncio import ImageAnnotatorGrpcAsyncIOTransport +try: + from google.api_core import client_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 ImageAnnotatorAsyncClient: """Service that performs Google Cloud Vision API detection tasks @@ -262,6 +272,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.vision_v1p3beta1.ImageAnnotatorAsyncClient`.", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ImageAnnotator", + "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.vision.v1p3beta1.ImageAnnotator", + "credentialsType": None, + }, + ) + async def batch_annotate_images( self, request: Optional[ @@ -273,7 +305,7 @@ async def batch_annotate_images( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Run image detection and annotation for a batch of images. @@ -317,8 +349,10 @@ async def sample_batch_annotate_images(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p3beta1.types.BatchAnnotateImagesResponse: @@ -377,7 +411,7 @@ async def async_batch_annotate_files( ] = None, retry: OptionalRetry = gapic_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"""Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple @@ -431,8 +465,10 @@ async def sample_async_batch_annotate_files(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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-vision/google/cloud/vision_v1p3beta1/services/image_annotator/client.py b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/client.py index ea5864856ff6..ba7808116b46 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/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 @@ -608,6 +618,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( @@ -673,6 +687,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.vision_v1p3beta1.ImageAnnotatorClient`.", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ImageAnnotator", + "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.vision.v1p3beta1.ImageAnnotator", + "credentialsType": None, + }, + ) + def batch_annotate_images( self, request: Optional[ @@ -684,7 +721,7 @@ def batch_annotate_images( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Run image detection and annotation for a batch of images. @@ -728,8 +765,10 @@ def sample_batch_annotate_images(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p3beta1.types.BatchAnnotateImagesResponse: @@ -785,7 +824,7 @@ def async_batch_annotate_files( ] = None, retry: OptionalRetry = gapic_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"""Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple @@ -839,8 +878,10 @@ def sample_async_batch_annotate_files(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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-vision/google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc.py b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc.py index 54ecf833617a..12feeafc9404 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/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.vision_v1p3beta1.types import image_annotator from .base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport +try: + from google.api_core import client_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.vision.v1p3beta1.ImageAnnotator", + "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.vision.v1p3beta1.ImageAnnotator", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ImageAnnotatorGrpcTransport(ImageAnnotatorTransport): """gRPC backend transport for ImageAnnotator. @@ -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 @@ -276,7 +364,7 @@ def batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_images" not in self._stubs: - self._stubs["batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ImageAnnotator/BatchAnnotateImages", request_serializer=image_annotator.BatchAnnotateImagesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateImagesResponse.deserialize, @@ -310,7 +398,9 @@ def async_batch_annotate_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "async_batch_annotate_files" not in self._stubs: - self._stubs["async_batch_annotate_files"] = self.grpc_channel.unary_unary( + self._stubs[ + "async_batch_annotate_files" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ImageAnnotator/AsyncBatchAnnotateFiles", request_serializer=image_annotator.AsyncBatchAnnotateFilesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -318,7 +408,7 @@ def async_batch_annotate_files( return self._stubs["async_batch_annotate_files"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc_asyncio.py b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc_asyncio.py index 355b5880f8c9..8d65c9b1655f 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc_asyncio.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/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.vision_v1p3beta1.types import image_annotator from .base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport from .grpc import ImageAnnotatorGrpcTransport +try: + from google.api_core import client_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.vision.v1p3beta1.ImageAnnotator", + "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.vision.v1p3beta1.ImageAnnotator", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ImageAnnotatorGrpcAsyncIOTransport(ImageAnnotatorTransport): """gRPC AsyncIO backend transport for ImageAnnotator. @@ -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. @@ -286,7 +371,7 @@ def batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_images" not in self._stubs: - self._stubs["batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ImageAnnotator/BatchAnnotateImages", request_serializer=image_annotator.BatchAnnotateImagesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateImagesResponse.deserialize, @@ -321,7 +406,9 @@ def async_batch_annotate_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "async_batch_annotate_files" not in self._stubs: - self._stubs["async_batch_annotate_files"] = self.grpc_channel.unary_unary( + self._stubs[ + "async_batch_annotate_files" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ImageAnnotator/AsyncBatchAnnotateFiles", request_serializer=image_annotator.AsyncBatchAnnotateFilesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -366,7 +453,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-vision/google/cloud/vision_v1p3beta1/services/image_annotator/transports/rest.py b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/transports/rest.py index 2c870cbd94c0..893070a36e86 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/transports/rest.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/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,9 +94,10 @@ def post_batch_annotate_images(self, response): def pre_async_batch_annotate_files( self, request: image_annotator.AsyncBatchAnnotateFilesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - image_annotator.AsyncBatchAnnotateFilesRequest, Sequence[Tuple[str, str]] + image_annotator.AsyncBatchAnnotateFilesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for async_batch_annotate_files @@ -111,8 +120,11 @@ def post_async_batch_annotate_files( def pre_batch_annotate_images( self, request: image_annotator.BatchAnnotateImagesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[image_annotator.BatchAnnotateImagesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + image_annotator.BatchAnnotateImagesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_annotate_images Override in a subclass to manipulate the request or metadata @@ -285,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]]] = (), ) -> operations_pb2.Operation: r"""Call the async batch annotate files method over HTTP. @@ -298,8 +310,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -312,6 +326,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseAsyncBatchAnnotateFiles._get_http_options() ) + request, metadata = self._interceptor.pre_async_batch_annotate_files( request, metadata ) @@ -328,6 +343,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p3beta1.ImageAnnotatorClient.AsyncBatchAnnotateFiles", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ImageAnnotator", + "rpcName": "AsyncBatchAnnotateFiles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ImageAnnotatorRestTransport._AsyncBatchAnnotateFiles._get_response( @@ -349,7 +391,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_async_batch_annotate_files(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p3beta1.ImageAnnotatorClient.async_batch_annotate_files", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ImageAnnotator", + "rpcName": "AsyncBatchAnnotateFiles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchAnnotateImages( @@ -388,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]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Call the batch annotate images method over HTTP. @@ -399,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: ~.image_annotator.BatchAnnotateImagesResponse: @@ -412,6 +478,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseBatchAnnotateImages._get_http_options() ) + request, metadata = self._interceptor.pre_batch_annotate_images( request, metadata ) @@ -428,6 +495,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p3beta1.ImageAnnotatorClient.BatchAnnotateImages", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ImageAnnotator", + "rpcName": "BatchAnnotateImages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImageAnnotatorRestTransport._BatchAnnotateImages._get_response( self._host, @@ -449,7 +543,31 @@ def __call__( pb_resp = image_annotator.BatchAnnotateImagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_annotate_images(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + image_annotator.BatchAnnotateImagesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p3beta1.ImageAnnotatorClient.batch_annotate_images", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ImageAnnotator", + "rpcName": "BatchAnnotateImages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/async_client.py b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/async_client.py index c89f89176a85..86bd928b665f 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/async_client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/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, ProductSearchTransport from .transports.grpc_asyncio import ProductSearchGrpcAsyncIOTransport +try: + from google.api_core import client_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 ProductSearchAsyncClient: """Manages Products and ProductSets of reference images for use in @@ -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.vision_v1p3beta1.ProductSearchAsyncClient`.", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "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.vision.v1p3beta1.ProductSearch", + "credentialsType": None, + }, + ) + async def create_product_set( self, request: Optional[ @@ -297,7 +329,7 @@ async def create_product_set( product_set_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]]] = (), ) -> product_search_service.ProductSet: r"""Creates and returns a new ProductSet resource. @@ -362,8 +394,10 @@ async def sample_create_product_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, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p3beta1.types.ProductSet: @@ -433,7 +467,7 @@ async def list_product_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.ListProductSetsAsyncPager: r"""Lists ProductSets in an unspecified order. @@ -484,8 +518,10 @@ async def sample_list_product_sets(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p3beta1.services.product_search.pagers.ListProductSetsAsyncPager: @@ -561,7 +597,7 @@ async def get_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Gets information associated with a ProductSet. @@ -610,8 +646,10 @@ async def sample_get_product_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, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p3beta1.types.ProductSet: @@ -678,7 +716,7 @@ async def update_product_set( 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]]] = (), ) -> product_search_service.ProductSet: r"""Makes changes to a ProductSet resource. Only display_name can be updated currently. @@ -737,8 +775,10 @@ async def sample_update_product_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, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p3beta1.types.ProductSet: @@ -808,7 +848,7 @@ async def delete_product_set( name: Optional[str] = None, retry: OptionalRetry = 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"""Permanently deletes a ProductSet. All Products and ReferenceImages in the ProductSet will be deleted. @@ -858,8 +898,10 @@ async def sample_delete_product_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, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -915,7 +957,7 @@ async def create_product( product_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]]] = (), ) -> product_search_service.Product: r"""Creates and returns a new product resource. @@ -984,8 +1026,10 @@ async def sample_create_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.cloud.vision_v1p3beta1.types.Product: @@ -1050,7 +1094,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 products in an unspecified order. @@ -1101,8 +1145,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.cloud.vision_v1p3beta1.services.product_search.pagers.ListProductsAsyncPager: @@ -1176,7 +1222,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]]] = (), ) -> product_search_service.Product: r"""Gets information associated with a Product. @@ -1225,8 +1271,10 @@ 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.cloud.vision_v1p3beta1.types.Product: @@ -1288,7 +1336,7 @@ async def update_product( 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]]] = (), ) -> product_search_service.Product: r"""Makes changes to a Product resource. Only display_name, description and labels can be updated right now. @@ -1356,8 +1404,10 @@ async def sample_update_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.cloud.vision_v1p3beta1.types.Product: @@ -1422,7 +1472,7 @@ async def delete_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]]] = (), ) -> None: r"""Permanently deletes a product and its reference images. @@ -1472,8 +1522,10 @@ async def sample_delete_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1529,7 +1581,7 @@ async def create_reference_image( reference_image_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]]] = (), ) -> product_search_service.ReferenceImage: r"""Creates and returns a new ReferenceImage resource. @@ -1618,8 +1670,10 @@ async def sample_create_reference_image(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p3beta1.types.ReferenceImage: @@ -1686,7 +1740,7 @@ async def delete_reference_image( name: Optional[str] = None, retry: OptionalRetry = 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"""Permanently deletes a reference image. @@ -1741,8 +1795,10 @@ async def sample_delete_reference_image(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -1796,7 +1852,7 @@ async def list_reference_images( 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.ListReferenceImagesAsyncPager: r"""Lists reference images. @@ -1849,8 +1905,10 @@ async def sample_list_reference_images(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p3beta1.services.product_search.pagers.ListReferenceImagesAsyncPager: @@ -1926,7 +1984,7 @@ async def get_reference_image( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Gets information associated with a ReferenceImage. @@ -1977,8 +2035,10 @@ async def sample_get_reference_image(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p3beta1.types.ReferenceImage: @@ -2042,7 +2102,7 @@ async def add_product_to_product_set( product: Optional[str] = None, retry: OptionalRetry = 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"""Adds a Product to the specified ProductSet. If the Product is already present, no change is made. @@ -2105,8 +2165,10 @@ async def sample_add_product_to_product_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, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -2165,7 +2227,7 @@ async def remove_product_from_product_set( product: Optional[str] = None, retry: OptionalRetry = 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"""Removes a Product from the specified ProductSet. @@ -2225,8 +2287,10 @@ async def sample_remove_product_from_product_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, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -2284,7 +2348,7 @@ async def list_products_in_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductsInProductSetAsyncPager: r"""Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the @@ -2339,8 +2403,10 @@ async def sample_list_products_in_product_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, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p3beta1.services.product_search.pagers.ListProductsInProductSetAsyncPager: @@ -2422,7 +2488,7 @@ async def import_product_sets( ] = None, retry: OptionalRetry = gapic_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"""Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. @@ -2489,8 +2555,10 @@ async def sample_import_product_sets(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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-vision/google/cloud/vision_v1p3beta1/services/product_search/client.py b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/client.py index e637b3c4472c..b5881aa7b3de 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/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 field_mask_pb2 # type: ignore @@ -650,6 +660,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( @@ -715,6 +729,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.vision_v1p3beta1.ProductSearchClient`.", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "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.vision.v1p3beta1.ProductSearch", + "credentialsType": None, + }, + ) + def create_product_set( self, request: Optional[ @@ -726,7 +763,7 @@ def create_product_set( product_set_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]]] = (), ) -> product_search_service.ProductSet: r"""Creates and returns a new ProductSet resource. @@ -791,8 +828,10 @@ def sample_create_product_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.cloud.vision_v1p3beta1.types.ProductSet: @@ -859,7 +898,7 @@ def list_product_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.ListProductSetsPager: r"""Lists ProductSets in an unspecified order. @@ -910,8 +949,10 @@ def sample_list_product_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.vision_v1p3beta1.services.product_search.pagers.ListProductSetsPager: @@ -984,7 +1025,7 @@ def get_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Gets information associated with a ProductSet. @@ -1033,8 +1074,10 @@ def sample_get_product_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.cloud.vision_v1p3beta1.types.ProductSet: @@ -1098,7 +1141,7 @@ def update_product_set( 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]]] = (), ) -> product_search_service.ProductSet: r"""Makes changes to a ProductSet resource. Only display_name can be updated currently. @@ -1157,8 +1200,10 @@ def sample_update_product_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.cloud.vision_v1p3beta1.types.ProductSet: @@ -1225,7 +1270,7 @@ def delete_product_set( name: Optional[str] = None, retry: OptionalRetry = 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"""Permanently deletes a ProductSet. All Products and ReferenceImages in the ProductSet will be deleted. @@ -1275,8 +1320,10 @@ def sample_delete_product_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1329,7 +1376,7 @@ def create_product( product_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]]] = (), ) -> product_search_service.Product: r"""Creates and returns a new product resource. @@ -1398,8 +1445,10 @@ def sample_create_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.cloud.vision_v1p3beta1.types.Product: @@ -1461,7 +1510,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 products in an unspecified order. @@ -1512,8 +1561,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.cloud.vision_v1p3beta1.services.product_search.pagers.ListProductsPager: @@ -1584,7 +1635,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]]] = (), ) -> product_search_service.Product: r"""Gets information associated with a Product. @@ -1633,8 +1684,10 @@ 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.cloud.vision_v1p3beta1.types.Product: @@ -1693,7 +1746,7 @@ def update_product( 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]]] = (), ) -> product_search_service.Product: r"""Makes changes to a Product resource. Only display_name, description and labels can be updated right now. @@ -1761,8 +1814,10 @@ def sample_update_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.cloud.vision_v1p3beta1.types.Product: @@ -1824,7 +1879,7 @@ def delete_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]]] = (), ) -> None: r"""Permanently deletes a product and its reference images. @@ -1874,8 +1929,10 @@ def sample_delete_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1928,7 +1985,7 @@ def create_reference_image( reference_image_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]]] = (), ) -> product_search_service.ReferenceImage: r"""Creates and returns a new ReferenceImage resource. @@ -2017,8 +2074,10 @@ def sample_create_reference_image(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p3beta1.types.ReferenceImage: @@ -2082,7 +2141,7 @@ def delete_reference_image( name: Optional[str] = None, retry: OptionalRetry = 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"""Permanently deletes a reference image. @@ -2137,8 +2196,10 @@ def sample_delete_reference_image(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -2189,7 +2250,7 @@ def list_reference_images( 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.ListReferenceImagesPager: r"""Lists reference images. @@ -2242,8 +2303,10 @@ def sample_list_reference_images(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p3beta1.services.product_search.pagers.ListReferenceImagesPager: @@ -2316,7 +2379,7 @@ def get_reference_image( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Gets information associated with a ReferenceImage. @@ -2367,8 +2430,10 @@ def sample_get_reference_image(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p3beta1.types.ReferenceImage: @@ -2429,7 +2494,7 @@ def add_product_to_product_set( product: Optional[str] = None, retry: OptionalRetry = 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"""Adds a Product to the specified ProductSet. If the Product is already present, no change is made. @@ -2492,8 +2557,10 @@ def sample_add_product_to_product_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2551,7 +2618,7 @@ def remove_product_from_product_set( product: Optional[str] = None, retry: OptionalRetry = 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"""Removes a Product from the specified ProductSet. @@ -2611,8 +2678,10 @@ def sample_remove_product_from_product_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2669,7 +2738,7 @@ def list_products_in_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductsInProductSetPager: r"""Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the @@ -2724,8 +2793,10 @@ def sample_list_products_in_product_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.cloud.vision_v1p3beta1.services.product_search.pagers.ListProductsInProductSetPager: @@ -2806,7 +2877,7 @@ def import_product_sets( ] = None, retry: OptionalRetry = gapic_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"""Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. @@ -2873,8 +2944,10 @@ def sample_import_product_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.api_core.operation.Operation: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/pagers.py b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/pagers.py index eec21adfcbbc..1b53dd1025b5 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/pagers.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/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 = product_search_service.ListProductSetsRequest(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 = product_search_service.ListProductSetsRequest(request) @@ -223,7 +227,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -237,8 +241,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = product_search_service.ListProductsRequest(request) @@ -297,7 +303,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. @@ -311,8 +317,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 = product_search_service.ListProductsRequest(request) @@ -375,7 +383,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -389,8 +397,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = product_search_service.ListReferenceImagesRequest(request) @@ -451,7 +461,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. @@ -465,8 +475,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 = product_search_service.ListReferenceImagesRequest(request) @@ -531,7 +543,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -545,8 +557,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = product_search_service.ListProductsInProductSetRequest(request) @@ -609,7 +623,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. @@ -623,8 +637,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 = product_search_service.ListProductsInProductSetRequest(request) diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/transports/grpc.py b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/transports/grpc.py index 8786d7073ea1..84a672dce485 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/transports/grpc.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/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.vision_v1p3beta1.types import product_search_service from .base import DEFAULT_CLIENT_INFO, ProductSearchTransport +try: + from google.api_core import client_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.vision.v1p3beta1.ProductSearch", + "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.vision.v1p3beta1.ProductSearch", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProductSearchGrpcTransport(ProductSearchTransport): """gRPC backend transport for ProductSearch. @@ -201,7 +282,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,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 @@ -297,7 +385,7 @@ def create_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product_set" not in self._stubs: - self._stubs["create_product_set"] = self.grpc_channel.unary_unary( + self._stubs["create_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/CreateProductSet", request_serializer=product_search_service.CreateProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -331,7 +419,7 @@ def list_product_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_product_sets" not in self._stubs: - self._stubs["list_product_sets"] = self.grpc_channel.unary_unary( + self._stubs["list_product_sets"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/ListProductSets", request_serializer=product_search_service.ListProductSetsRequest.serialize, response_deserializer=product_search_service.ListProductSetsResponse.deserialize, @@ -363,7 +451,7 @@ def get_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product_set" not in self._stubs: - self._stubs["get_product_set"] = self.grpc_channel.unary_unary( + self._stubs["get_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/GetProductSet", request_serializer=product_search_service.GetProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -400,7 +488,7 @@ def update_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product_set" not in self._stubs: - self._stubs["update_product_set"] = self.grpc_channel.unary_unary( + self._stubs["update_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/UpdateProductSet", request_serializer=product_search_service.UpdateProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -434,7 +522,7 @@ def delete_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product_set" not in self._stubs: - self._stubs["delete_product_set"] = self.grpc_channel.unary_unary( + self._stubs["delete_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/DeleteProductSet", request_serializer=product_search_service.DeleteProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -471,7 +559,7 @@ def create_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product" not in self._stubs: - self._stubs["create_product"] = self.grpc_channel.unary_unary( + self._stubs["create_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/CreateProduct", request_serializer=product_search_service.CreateProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -505,7 +593,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.cloud.vision.v1p3beta1.ProductSearch/ListProducts", request_serializer=product_search_service.ListProductsRequest.serialize, response_deserializer=product_search_service.ListProductsResponse.deserialize, @@ -537,7 +625,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.cloud.vision.v1p3beta1.ProductSearch/GetProduct", request_serializer=product_search_service.GetProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -580,7 +668,7 @@ def update_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product" not in self._stubs: - self._stubs["update_product"] = self.grpc_channel.unary_unary( + self._stubs["update_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/UpdateProduct", request_serializer=product_search_service.UpdateProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -614,7 +702,7 @@ def delete_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product" not in self._stubs: - self._stubs["delete_product"] = self.grpc_channel.unary_unary( + self._stubs["delete_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/DeleteProduct", request_serializer=product_search_service.DeleteProductRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -664,7 +752,7 @@ def create_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_reference_image" not in self._stubs: - self._stubs["create_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["create_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/CreateReferenceImage", request_serializer=product_search_service.CreateReferenceImageRequest.serialize, response_deserializer=product_search_service.ReferenceImage.deserialize, @@ -703,7 +791,7 @@ def delete_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_reference_image" not in self._stubs: - self._stubs["delete_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["delete_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/DeleteReferenceImage", request_serializer=product_search_service.DeleteReferenceImageRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -738,7 +826,7 @@ def list_reference_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_reference_images" not in self._stubs: - self._stubs["list_reference_images"] = self.grpc_channel.unary_unary( + self._stubs["list_reference_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/ListReferenceImages", request_serializer=product_search_service.ListReferenceImagesRequest.serialize, response_deserializer=product_search_service.ListReferenceImagesResponse.deserialize, @@ -771,7 +859,7 @@ def get_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_reference_image" not in self._stubs: - self._stubs["get_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["get_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/GetReferenceImage", request_serializer=product_search_service.GetReferenceImageRequest.serialize, response_deserializer=product_search_service.ReferenceImage.deserialize, @@ -807,7 +895,9 @@ def add_product_to_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_product_to_product_set" not in self._stubs: - self._stubs["add_product_to_product_set"] = self.grpc_channel.unary_unary( + self._stubs[ + "add_product_to_product_set" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/AddProductToProductSet", request_serializer=product_search_service.AddProductToProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -843,7 +933,7 @@ def remove_product_from_product_set( if "remove_product_from_product_set" not in self._stubs: self._stubs[ "remove_product_from_product_set" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/RemoveProductFromProductSet", request_serializer=product_search_service.RemoveProductFromProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -879,7 +969,9 @@ def list_products_in_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products_in_product_set" not in self._stubs: - self._stubs["list_products_in_product_set"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_products_in_product_set" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/ListProductsInProductSet", request_serializer=product_search_service.ListProductsInProductSetRequest.serialize, response_deserializer=product_search_service.ListProductsInProductSetResponse.deserialize, @@ -918,7 +1010,7 @@ def import_product_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_product_sets" not in self._stubs: - self._stubs["import_product_sets"] = self.grpc_channel.unary_unary( + self._stubs["import_product_sets"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/ImportProductSets", request_serializer=product_search_service.ImportProductSetsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -926,7 +1018,7 @@ def import_product_sets( return self._stubs["import_product_sets"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/transports/grpc_asyncio.py b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/transports/grpc_asyncio.py index b40242d5afd4..a55c851950ca 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/transports/grpc_asyncio.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/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.vision_v1p3beta1.types import product_search_service from .base import DEFAULT_CLIENT_INFO, ProductSearchTransport from .grpc import ProductSearchGrpcTransport +try: + from google.api_core import client_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.vision.v1p3beta1.ProductSearch", + "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.vision.v1p3beta1.ProductSearch", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProductSearchGrpcAsyncIOTransport(ProductSearchTransport): """gRPC AsyncIO backend transport for ProductSearch. @@ -248,10 +330,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 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. @@ -307,7 +392,7 @@ def create_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product_set" not in self._stubs: - self._stubs["create_product_set"] = self.grpc_channel.unary_unary( + self._stubs["create_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/CreateProductSet", request_serializer=product_search_service.CreateProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -341,7 +426,7 @@ def list_product_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_product_sets" not in self._stubs: - self._stubs["list_product_sets"] = self.grpc_channel.unary_unary( + self._stubs["list_product_sets"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/ListProductSets", request_serializer=product_search_service.ListProductSetsRequest.serialize, response_deserializer=product_search_service.ListProductSetsResponse.deserialize, @@ -374,7 +459,7 @@ def get_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product_set" not in self._stubs: - self._stubs["get_product_set"] = self.grpc_channel.unary_unary( + self._stubs["get_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/GetProductSet", request_serializer=product_search_service.GetProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -411,7 +496,7 @@ def update_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product_set" not in self._stubs: - self._stubs["update_product_set"] = self.grpc_channel.unary_unary( + self._stubs["update_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/UpdateProductSet", request_serializer=product_search_service.UpdateProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -447,7 +532,7 @@ def delete_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product_set" not in self._stubs: - self._stubs["delete_product_set"] = self.grpc_channel.unary_unary( + self._stubs["delete_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/DeleteProductSet", request_serializer=product_search_service.DeleteProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -485,7 +570,7 @@ def create_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product" not in self._stubs: - self._stubs["create_product"] = self.grpc_channel.unary_unary( + self._stubs["create_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/CreateProduct", request_serializer=product_search_service.CreateProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -519,7 +604,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.cloud.vision.v1p3beta1.ProductSearch/ListProducts", request_serializer=product_search_service.ListProductsRequest.serialize, response_deserializer=product_search_service.ListProductsResponse.deserialize, @@ -552,7 +637,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.cloud.vision.v1p3beta1.ProductSearch/GetProduct", request_serializer=product_search_service.GetProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -596,7 +681,7 @@ def update_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product" not in self._stubs: - self._stubs["update_product"] = self.grpc_channel.unary_unary( + self._stubs["update_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/UpdateProduct", request_serializer=product_search_service.UpdateProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -632,7 +717,7 @@ def delete_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product" not in self._stubs: - self._stubs["delete_product"] = self.grpc_channel.unary_unary( + self._stubs["delete_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/DeleteProduct", request_serializer=product_search_service.DeleteProductRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -682,7 +767,7 @@ def create_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_reference_image" not in self._stubs: - self._stubs["create_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["create_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/CreateReferenceImage", request_serializer=product_search_service.CreateReferenceImageRequest.serialize, response_deserializer=product_search_service.ReferenceImage.deserialize, @@ -721,7 +806,7 @@ def delete_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_reference_image" not in self._stubs: - self._stubs["delete_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["delete_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/DeleteReferenceImage", request_serializer=product_search_service.DeleteReferenceImageRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -756,7 +841,7 @@ def list_reference_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_reference_images" not in self._stubs: - self._stubs["list_reference_images"] = self.grpc_channel.unary_unary( + self._stubs["list_reference_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/ListReferenceImages", request_serializer=product_search_service.ListReferenceImagesRequest.serialize, response_deserializer=product_search_service.ListReferenceImagesResponse.deserialize, @@ -789,7 +874,7 @@ def get_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_reference_image" not in self._stubs: - self._stubs["get_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["get_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/GetReferenceImage", request_serializer=product_search_service.GetReferenceImageRequest.serialize, response_deserializer=product_search_service.ReferenceImage.deserialize, @@ -826,7 +911,9 @@ def add_product_to_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_product_to_product_set" not in self._stubs: - self._stubs["add_product_to_product_set"] = self.grpc_channel.unary_unary( + self._stubs[ + "add_product_to_product_set" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/AddProductToProductSet", request_serializer=product_search_service.AddProductToProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -863,7 +950,7 @@ def remove_product_from_product_set( if "remove_product_from_product_set" not in self._stubs: self._stubs[ "remove_product_from_product_set" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/RemoveProductFromProductSet", request_serializer=product_search_service.RemoveProductFromProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -899,7 +986,9 @@ def list_products_in_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products_in_product_set" not in self._stubs: - self._stubs["list_products_in_product_set"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_products_in_product_set" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/ListProductsInProductSet", request_serializer=product_search_service.ListProductsInProductSetRequest.serialize, response_deserializer=product_search_service.ListProductsInProductSetResponse.deserialize, @@ -939,7 +1028,7 @@ def import_product_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_product_sets" not in self._stubs: - self._stubs["import_product_sets"] = self.grpc_channel.unary_unary( + self._stubs["import_product_sets"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/ImportProductSets", request_serializer=product_search_service.ImportProductSetsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1203,7 +1292,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-vision/google/cloud/vision_v1p3beta1/services/product_search/transports/rest.py b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/transports/rest.py index ecff283c0049..33d4b036fdb0 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/transports/rest.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/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, @@ -195,9 +203,10 @@ def post_update_product_set(self, response): def pre_add_product_to_product_set( self, request: product_search_service.AddProductToProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.AddProductToProductSetRequest, Sequence[Tuple[str, str]] + product_search_service.AddProductToProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for add_product_to_product_set @@ -209,8 +218,11 @@ def pre_add_product_to_product_set( def pre_create_product( self, request: product_search_service.CreateProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.CreateProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.CreateProductRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_product Override in a subclass to manipulate the request or metadata @@ -232,9 +244,10 @@ def post_create_product( def pre_create_product_set( self, request: product_search_service.CreateProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.CreateProductSetRequest, Sequence[Tuple[str, str]] + product_search_service.CreateProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_product_set @@ -257,9 +270,10 @@ def post_create_product_set( def pre_create_reference_image( self, request: product_search_service.CreateReferenceImageRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.CreateReferenceImageRequest, Sequence[Tuple[str, str]] + product_search_service.CreateReferenceImageRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_reference_image @@ -282,8 +296,11 @@ def post_create_reference_image( def pre_delete_product( self, request: product_search_service.DeleteProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.DeleteProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.DeleteProductRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_product Override in a subclass to manipulate the request or metadata @@ -294,9 +311,10 @@ def pre_delete_product( def pre_delete_product_set( self, request: product_search_service.DeleteProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.DeleteProductSetRequest, Sequence[Tuple[str, str]] + product_search_service.DeleteProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_product_set @@ -308,9 +326,10 @@ def pre_delete_product_set( def pre_delete_reference_image( self, request: product_search_service.DeleteReferenceImageRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.DeleteReferenceImageRequest, Sequence[Tuple[str, str]] + product_search_service.DeleteReferenceImageRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_reference_image @@ -322,8 +341,11 @@ def pre_delete_reference_image( def pre_get_product( self, request: product_search_service.GetProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.GetProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.GetProductRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_product Override in a subclass to manipulate the request or metadata @@ -345,8 +367,11 @@ def post_get_product( def pre_get_product_set( self, request: product_search_service.GetProductSetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.GetProductSetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.GetProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_product_set Override in a subclass to manipulate the request or metadata @@ -368,9 +393,10 @@ def post_get_product_set( def pre_get_reference_image( self, request: product_search_service.GetReferenceImageRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.GetReferenceImageRequest, Sequence[Tuple[str, str]] + product_search_service.GetReferenceImageRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_reference_image @@ -393,9 +419,10 @@ def post_get_reference_image( def pre_import_product_sets( self, request: product_search_service.ImportProductSetsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.ImportProductSetsRequest, Sequence[Tuple[str, str]] + product_search_service.ImportProductSetsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for import_product_sets @@ -418,8 +445,11 @@ def post_import_product_sets( def pre_list_products( self, request: product_search_service.ListProductsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.ListProductsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.ListProductsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_products Override in a subclass to manipulate the request or metadata @@ -441,9 +471,10 @@ def post_list_products( def pre_list_product_sets( self, request: product_search_service.ListProductSetsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.ListProductSetsRequest, Sequence[Tuple[str, str]] + product_search_service.ListProductSetsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_product_sets @@ -466,10 +497,10 @@ def post_list_product_sets( def pre_list_products_in_product_set( self, request: product_search_service.ListProductsInProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ product_search_service.ListProductsInProductSetRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_products_in_product_set @@ -492,9 +523,10 @@ def post_list_products_in_product_set( def pre_list_reference_images( self, request: product_search_service.ListReferenceImagesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.ListReferenceImagesRequest, Sequence[Tuple[str, str]] + product_search_service.ListReferenceImagesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_reference_images @@ -517,10 +549,10 @@ def post_list_reference_images( def pre_remove_product_from_product_set( self, request: product_search_service.RemoveProductFromProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ product_search_service.RemoveProductFromProductSetRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for remove_product_from_product_set @@ -532,8 +564,11 @@ def pre_remove_product_from_product_set( def pre_update_product( self, request: product_search_service.UpdateProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.UpdateProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.UpdateProductRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_product Override in a subclass to manipulate the request or metadata @@ -555,9 +590,10 @@ def post_update_product( def pre_update_product_set( self, request: product_search_service.UpdateProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.UpdateProductSetRequest, Sequence[Tuple[str, str]] + product_search_service.UpdateProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_product_set @@ -747,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]]] = (), ): r"""Call the add product to product set method over HTTP. @@ -759,13 +795,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 = ( _BaseProductSearchRestTransport._BaseAddProductToProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_add_product_to_product_set( request, metadata ) @@ -782,6 +821,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p3beta1.ProductSearchClient.AddProductToProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "AddProductToProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._AddProductToProductSet._get_response( self._host, @@ -833,7 +899,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Call the create product method over HTTP. @@ -843,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: ~.product_search_service.Product: @@ -854,6 +922,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseCreateProduct._get_http_options() ) + request, metadata = self._interceptor.pre_create_product(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseCreateProduct._get_transcoded_request( http_options, request @@ -868,6 +937,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p3beta1.ProductSearchClient.CreateProduct", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "CreateProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._CreateProduct._get_response( self._host, @@ -889,7 +985,29 @@ def __call__( pb_resp = product_search_service.Product.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.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.cloud.vision_v1p3beta1.ProductSearchClient.create_product", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "CreateProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateProductSet( @@ -927,7 +1045,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Call the create product set method over HTTP. @@ -937,8 +1055,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.product_search_service.ProductSet: @@ -953,6 +1073,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseCreateProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_create_product_set( request, metadata ) @@ -969,6 +1090,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p3beta1.ProductSearchClient.CreateProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "CreateProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._CreateProductSet._get_response( self._host, @@ -990,7 +1138,31 @@ def __call__( pb_resp = product_search_service.ProductSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_product_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ProductSet.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p3beta1.ProductSearchClient.create_product_set", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "CreateProductSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateReferenceImage( @@ -1028,7 +1200,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Call the create reference image method over HTTP. @@ -1038,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: ~.product_search_service.ReferenceImage: @@ -1051,6 +1225,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseCreateReferenceImage._get_http_options() ) + request, metadata = self._interceptor.pre_create_reference_image( request, metadata ) @@ -1067,6 +1242,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p3beta1.ProductSearchClient.CreateReferenceImage", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "CreateReferenceImage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._CreateReferenceImage._get_response( self._host, @@ -1088,7 +1290,31 @@ def __call__( pb_resp = product_search_service.ReferenceImage.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_reference_image(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ReferenceImage.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p3beta1.ProductSearchClient.create_reference_image", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "CreateReferenceImage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteProduct( @@ -1125,7 +1351,7 @@ 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 method over HTTP. @@ -1135,13 +1361,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 = ( _BaseProductSearchRestTransport._BaseDeleteProduct._get_http_options() ) + request, metadata = self._interceptor.pre_delete_product(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseDeleteProduct._get_transcoded_request( http_options, request @@ -1152,6 +1381,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p3beta1.ProductSearchClient.DeleteProduct", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "DeleteProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._DeleteProduct._get_response( self._host, @@ -1201,7 +1457,7 @@ 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 set method over HTTP. @@ -1211,13 +1467,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 = ( _BaseProductSearchRestTransport._BaseDeleteProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_delete_product_set( request, metadata ) @@ -1230,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p3beta1.ProductSearchClient.DeleteProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "DeleteProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._DeleteProductSet._get_response( self._host, @@ -1279,7 +1565,7 @@ 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 reference image method over HTTP. @@ -1289,13 +1575,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 = ( _BaseProductSearchRestTransport._BaseDeleteReferenceImage._get_http_options() ) + request, metadata = self._interceptor.pre_delete_reference_image( request, metadata ) @@ -1308,6 +1597,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p3beta1.ProductSearchClient.DeleteReferenceImage", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "DeleteReferenceImage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._DeleteReferenceImage._get_response( self._host, @@ -1357,7 +1673,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Call the get product method over HTTP. @@ -1367,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: ~.product_search_service.Product: @@ -1378,6 +1696,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseGetProduct._get_http_options() ) + request, metadata = self._interceptor.pre_get_product(request, metadata) transcoded_request = ( _BaseProductSearchRestTransport._BaseGetProduct._get_transcoded_request( @@ -1392,6 +1711,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p3beta1.ProductSearchClient.GetProduct", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "GetProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._GetProduct._get_response( self._host, @@ -1412,7 +1758,29 @@ def __call__( pb_resp = product_search_service.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 = product_search_service.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.cloud.vision_v1p3beta1.ProductSearchClient.get_product", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "GetProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetProductSet( @@ -1449,7 +1817,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Call the get product set method over HTTP. @@ -1459,8 +1827,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.product_search_service.ProductSet: @@ -1475,6 +1845,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseGetProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_get_product_set(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseGetProductSet._get_transcoded_request( http_options, request @@ -1485,6 +1856,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p3beta1.ProductSearchClient.GetProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "GetProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._GetProductSet._get_response( self._host, @@ -1505,7 +1903,31 @@ def __call__( pb_resp = product_search_service.ProductSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_product_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ProductSet.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p3beta1.ProductSearchClient.get_product_set", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "GetProductSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetReferenceImage( @@ -1542,7 +1964,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Call the get reference image method over HTTP. @@ -1552,8 +1974,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.product_search_service.ReferenceImage: @@ -1565,6 +1989,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseGetReferenceImage._get_http_options() ) + request, metadata = self._interceptor.pre_get_reference_image( request, metadata ) @@ -1577,6 +2002,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p3beta1.ProductSearchClient.GetReferenceImage", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "GetReferenceImage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._GetReferenceImage._get_response( self._host, @@ -1597,7 +2049,31 @@ def __call__( pb_resp = product_search_service.ReferenceImage.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_reference_image(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ReferenceImage.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p3beta1.ProductSearchClient.get_reference_image", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "GetReferenceImage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportProductSets( @@ -1635,7 +2111,7 @@ 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 product sets method over HTTP. @@ -1645,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: ~.operations_pb2.Operation: @@ -1659,6 +2137,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseImportProductSets._get_http_options() ) + request, metadata = self._interceptor.pre_import_product_sets( request, metadata ) @@ -1675,6 +2154,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p3beta1.ProductSearchClient.ImportProductSets", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "ImportProductSets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._ImportProductSets._get_response( self._host, @@ -1694,7 +2200,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_product_sets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p3beta1.ProductSearchClient.import_product_sets", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "ImportProductSets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProducts( @@ -1731,7 +2259,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ListProductsResponse: r"""Call the list products method over HTTP. @@ -1741,8 +2269,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.product_search_service.ListProductsResponse: @@ -1752,6 +2282,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseListProducts._get_http_options() ) + request, metadata = self._interceptor.pre_list_products(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseListProducts._get_transcoded_request( http_options, request @@ -1762,6 +2293,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p3beta1.ProductSearchClient.ListProducts", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "ListProducts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._ListProducts._get_response( self._host, @@ -1782,7 +2340,31 @@ def __call__( pb_resp = product_search_service.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 = ( + product_search_service.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.cloud.vision_v1p3beta1.ProductSearchClient.list_products", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "ListProducts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProductSets( @@ -1819,7 +2401,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ListProductSetsResponse: r"""Call the list product sets method over HTTP. @@ -1829,8 +2411,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.product_search_service.ListProductSetsResponse: @@ -1840,6 +2424,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseListProductSets._get_http_options() ) + request, metadata = self._interceptor.pre_list_product_sets( request, metadata ) @@ -1852,6 +2437,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p3beta1.ProductSearchClient.ListProductSets", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "ListProductSets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._ListProductSets._get_response( self._host, @@ -1872,7 +2484,31 @@ def __call__( pb_resp = product_search_service.ListProductSetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_product_sets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + product_search_service.ListProductSetsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p3beta1.ProductSearchClient.list_product_sets", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "ListProductSets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProductsInProductSet( @@ -1910,7 +2546,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ListProductsInProductSetResponse: r"""Call the list products in product set method over HTTP. @@ -1922,8 +2558,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.product_search_service.ListProductsInProductSetResponse: @@ -1935,6 +2573,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseListProductsInProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_list_products_in_product_set( request, metadata ) @@ -1947,6 +2586,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p3beta1.ProductSearchClient.ListProductsInProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "ListProductsInProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ProductSearchRestTransport._ListProductsInProductSet._get_response( @@ -1969,7 +2635,33 @@ def __call__( pb_resp = product_search_service.ListProductsInProductSetResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_products_in_product_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + product_search_service.ListProductsInProductSetResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p3beta1.ProductSearchClient.list_products_in_product_set", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "ListProductsInProductSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListReferenceImages( @@ -2006,7 +2698,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ListReferenceImagesResponse: r"""Call the list reference images method over HTTP. @@ -2016,8 +2708,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.product_search_service.ListReferenceImagesResponse: @@ -2027,6 +2721,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseListReferenceImages._get_http_options() ) + request, metadata = self._interceptor.pre_list_reference_images( request, metadata ) @@ -2039,6 +2734,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p3beta1.ProductSearchClient.ListReferenceImages", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "ListReferenceImages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._ListReferenceImages._get_response( self._host, @@ -2059,7 +2781,33 @@ def __call__( pb_resp = product_search_service.ListReferenceImagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_reference_images(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + product_search_service.ListReferenceImagesResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p3beta1.ProductSearchClient.list_reference_images", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "ListReferenceImages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveProductFromProductSet( @@ -2098,7 +2846,7 @@ 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 remove product from product set method over HTTP. @@ -2110,13 +2858,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 = ( _BaseProductSearchRestTransport._BaseRemoveProductFromProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_remove_product_from_product_set( request, metadata ) @@ -2133,6 +2884,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p3beta1.ProductSearchClient.RemoveProductFromProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "RemoveProductFromProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ProductSearchRestTransport._RemoveProductFromProductSet._get_response( @@ -2186,7 +2964,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Call the update product method over HTTP. @@ -2196,8 +2974,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.product_search_service.Product: @@ -2207,6 +2987,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseUpdateProduct._get_http_options() ) + request, metadata = self._interceptor.pre_update_product(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseUpdateProduct._get_transcoded_request( http_options, request @@ -2221,6 +3002,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p3beta1.ProductSearchClient.UpdateProduct", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "UpdateProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._UpdateProduct._get_response( self._host, @@ -2242,7 +3050,29 @@ def __call__( pb_resp = product_search_service.Product.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.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.cloud.vision_v1p3beta1.ProductSearchClient.update_product", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "UpdateProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateProductSet( @@ -2280,7 +3110,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Call the update product set method over HTTP. @@ -2290,8 +3120,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.product_search_service.ProductSet: @@ -2306,6 +3138,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseUpdateProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_update_product_set( request, metadata ) @@ -2322,6 +3155,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p3beta1.ProductSearchClient.UpdateProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "UpdateProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._UpdateProductSet._get_response( self._host, @@ -2343,7 +3203,31 @@ def __call__( pb_resp = product_search_service.ProductSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_product_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ProductSet.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p3beta1.ProductSearchClient.update_product_set", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "UpdateProductSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/gapic_version.py b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/gapic_version.py index e194ca38362b..558c8aab67c5 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/gapic_version.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.8.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/async_client.py b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/async_client.py index 72df8a7df27f..86929de94d8e 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/async_client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/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, ImageAnnotatorTransport from .transports.grpc_asyncio import ImageAnnotatorGrpcAsyncIOTransport +try: + from google.api_core import client_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 ImageAnnotatorAsyncClient: """Service that performs Google Cloud Vision API detection tasks @@ -262,6 +272,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.vision_v1p4beta1.ImageAnnotatorAsyncClient`.", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ImageAnnotator", + "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.vision.v1p4beta1.ImageAnnotator", + "credentialsType": None, + }, + ) + async def batch_annotate_images( self, request: Optional[ @@ -273,7 +305,7 @@ async def batch_annotate_images( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Run image detection and annotation for a batch of images. @@ -317,8 +349,10 @@ async def sample_batch_annotate_images(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p4beta1.types.BatchAnnotateImagesResponse: @@ -375,7 +409,7 @@ async def batch_annotate_files( requests: Optional[MutableSequence[image_annotator.AnnotateFileRequest]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateFilesResponse: r"""Service that performs image detection and annotation for a batch of files. Now only "application/pdf", @@ -428,8 +462,10 @@ async def sample_batch_annotate_files(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p4beta1.types.BatchAnnotateFilesResponse: @@ -487,7 +523,7 @@ async def async_batch_annotate_images( output_config: Optional[image_annotator.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"""Run asynchronous image detection and annotation for a list of images. @@ -552,8 +588,10 @@ async def sample_async_batch_annotate_images(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -625,7 +663,7 @@ async def async_batch_annotate_files( ] = None, retry: OptionalRetry = gapic_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"""Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple @@ -679,8 +717,10 @@ async def sample_async_batch_annotate_files(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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-vision/google/cloud/vision_v1p4beta1/services/image_annotator/client.py b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/client.py index c32c3e3889fa..d26392f790de 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/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 @@ -608,6 +618,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( @@ -673,6 +687,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.vision_v1p4beta1.ImageAnnotatorClient`.", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ImageAnnotator", + "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.vision.v1p4beta1.ImageAnnotator", + "credentialsType": None, + }, + ) + def batch_annotate_images( self, request: Optional[ @@ -684,7 +721,7 @@ def batch_annotate_images( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Run image detection and annotation for a batch of images. @@ -728,8 +765,10 @@ def sample_batch_annotate_images(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p4beta1.types.BatchAnnotateImagesResponse: @@ -783,7 +822,7 @@ def batch_annotate_files( requests: Optional[MutableSequence[image_annotator.AnnotateFileRequest]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateFilesResponse: r"""Service that performs image detection and annotation for a batch of files. Now only "application/pdf", @@ -836,8 +875,10 @@ def sample_batch_annotate_files(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p4beta1.types.BatchAnnotateFilesResponse: @@ -892,7 +933,7 @@ def async_batch_annotate_images( output_config: Optional[image_annotator.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"""Run asynchronous image detection and annotation for a list of images. @@ -957,8 +998,10 @@ def sample_async_batch_annotate_images(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1029,7 +1072,7 @@ def async_batch_annotate_files( ] = None, retry: OptionalRetry = gapic_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"""Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple @@ -1083,8 +1126,10 @@ def sample_async_batch_annotate_files(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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-vision/google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc.py b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc.py index 12437efda993..8684ac7c8674 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/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.vision_v1p4beta1.types import image_annotator from .base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport +try: + from google.api_core import client_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.vision.v1p4beta1.ImageAnnotator", + "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.vision.v1p4beta1.ImageAnnotator", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ImageAnnotatorGrpcTransport(ImageAnnotatorTransport): """gRPC backend transport for ImageAnnotator. @@ -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 @@ -276,7 +364,7 @@ def batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_images" not in self._stubs: - self._stubs["batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ImageAnnotator/BatchAnnotateImages", request_serializer=image_annotator.BatchAnnotateImagesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateImagesResponse.deserialize, @@ -313,7 +401,7 @@ def batch_annotate_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_files" not in self._stubs: - self._stubs["batch_annotate_files"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_files"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ImageAnnotator/BatchAnnotateFiles", request_serializer=image_annotator.BatchAnnotateFilesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateFilesResponse.deserialize, @@ -352,7 +440,9 @@ def async_batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "async_batch_annotate_images" not in self._stubs: - self._stubs["async_batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs[ + "async_batch_annotate_images" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ImageAnnotator/AsyncBatchAnnotateImages", request_serializer=image_annotator.AsyncBatchAnnotateImagesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -386,7 +476,9 @@ def async_batch_annotate_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "async_batch_annotate_files" not in self._stubs: - self._stubs["async_batch_annotate_files"] = self.grpc_channel.unary_unary( + self._stubs[ + "async_batch_annotate_files" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ImageAnnotator/AsyncBatchAnnotateFiles", request_serializer=image_annotator.AsyncBatchAnnotateFilesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -394,7 +486,7 @@ def async_batch_annotate_files( return self._stubs["async_batch_annotate_files"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc_asyncio.py b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc_asyncio.py index a51ad52ec0e6..7797ee1575f8 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc_asyncio.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/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.vision_v1p4beta1.types import image_annotator from .base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport from .grpc import ImageAnnotatorGrpcTransport +try: + from google.api_core import client_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.vision.v1p4beta1.ImageAnnotator", + "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.vision.v1p4beta1.ImageAnnotator", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ImageAnnotatorGrpcAsyncIOTransport(ImageAnnotatorTransport): """gRPC AsyncIO backend transport for ImageAnnotator. @@ -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. @@ -286,7 +371,7 @@ def batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_images" not in self._stubs: - self._stubs["batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ImageAnnotator/BatchAnnotateImages", request_serializer=image_annotator.BatchAnnotateImagesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateImagesResponse.deserialize, @@ -323,7 +408,7 @@ def batch_annotate_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_files" not in self._stubs: - self._stubs["batch_annotate_files"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_files"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ImageAnnotator/BatchAnnotateFiles", request_serializer=image_annotator.BatchAnnotateFilesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateFilesResponse.deserialize, @@ -363,7 +448,9 @@ def async_batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "async_batch_annotate_images" not in self._stubs: - self._stubs["async_batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs[ + "async_batch_annotate_images" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ImageAnnotator/AsyncBatchAnnotateImages", request_serializer=image_annotator.AsyncBatchAnnotateImagesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -398,7 +485,9 @@ def async_batch_annotate_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "async_batch_annotate_files" not in self._stubs: - self._stubs["async_batch_annotate_files"] = self.grpc_channel.unary_unary( + self._stubs[ + "async_batch_annotate_files" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ImageAnnotator/AsyncBatchAnnotateFiles", request_serializer=image_annotator.AsyncBatchAnnotateFilesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -464,7 +553,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-vision/google/cloud/vision_v1p4beta1/services/image_annotator/transports/rest.py b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/transports/rest.py index 657058388ad6..6c7b44849bc1 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/transports/rest.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/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, @@ -102,9 +110,10 @@ def post_batch_annotate_images(self, response): def pre_async_batch_annotate_files( self, request: image_annotator.AsyncBatchAnnotateFilesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - image_annotator.AsyncBatchAnnotateFilesRequest, Sequence[Tuple[str, str]] + image_annotator.AsyncBatchAnnotateFilesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for async_batch_annotate_files @@ -127,9 +136,10 @@ def post_async_batch_annotate_files( def pre_async_batch_annotate_images( self, request: image_annotator.AsyncBatchAnnotateImagesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - image_annotator.AsyncBatchAnnotateImagesRequest, Sequence[Tuple[str, str]] + image_annotator.AsyncBatchAnnotateImagesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for async_batch_annotate_images @@ -152,8 +162,11 @@ def post_async_batch_annotate_images( def pre_batch_annotate_files( self, request: image_annotator.BatchAnnotateFilesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[image_annotator.BatchAnnotateFilesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + image_annotator.BatchAnnotateFilesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_annotate_files Override in a subclass to manipulate the request or metadata @@ -175,8 +188,11 @@ def post_batch_annotate_files( def pre_batch_annotate_images( self, request: image_annotator.BatchAnnotateImagesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[image_annotator.BatchAnnotateImagesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + image_annotator.BatchAnnotateImagesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_annotate_images Override in a subclass to manipulate the request or metadata @@ -349,7 +365,7 @@ 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 async batch annotate files method over HTTP. @@ -362,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: ~.operations_pb2.Operation: @@ -376,6 +394,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseAsyncBatchAnnotateFiles._get_http_options() ) + request, metadata = self._interceptor.pre_async_batch_annotate_files( request, metadata ) @@ -392,6 +411,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p4beta1.ImageAnnotatorClient.AsyncBatchAnnotateFiles", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ImageAnnotator", + "rpcName": "AsyncBatchAnnotateFiles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ImageAnnotatorRestTransport._AsyncBatchAnnotateFiles._get_response( @@ -413,7 +459,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_async_batch_annotate_files(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p4beta1.ImageAnnotatorClient.async_batch_annotate_files", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ImageAnnotator", + "rpcName": "AsyncBatchAnnotateFiles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AsyncBatchAnnotateImages( @@ -452,7 +520,7 @@ 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 async batch annotate images method over HTTP. @@ -464,8 +532,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -478,6 +548,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseAsyncBatchAnnotateImages._get_http_options() ) + request, metadata = self._interceptor.pre_async_batch_annotate_images( request, metadata ) @@ -494,6 +565,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p4beta1.ImageAnnotatorClient.AsyncBatchAnnotateImages", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ImageAnnotator", + "rpcName": "AsyncBatchAnnotateImages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ImageAnnotatorRestTransport._AsyncBatchAnnotateImages._get_response( @@ -515,7 +613,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_async_batch_annotate_images(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p4beta1.ImageAnnotatorClient.async_batch_annotate_images", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ImageAnnotator", + "rpcName": "AsyncBatchAnnotateImages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchAnnotateFiles( @@ -553,7 +673,7 @@ 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_annotator.BatchAnnotateFilesResponse: r"""Call the batch annotate files method over HTTP. @@ -564,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: ~.image_annotator.BatchAnnotateFilesResponse: @@ -575,6 +697,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseBatchAnnotateFiles._get_http_options() ) + request, metadata = self._interceptor.pre_batch_annotate_files( request, metadata ) @@ -591,6 +714,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p4beta1.ImageAnnotatorClient.BatchAnnotateFiles", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ImageAnnotator", + "rpcName": "BatchAnnotateFiles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImageAnnotatorRestTransport._BatchAnnotateFiles._get_response( self._host, @@ -612,7 +762,31 @@ def __call__( pb_resp = image_annotator.BatchAnnotateFilesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_annotate_files(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + image_annotator.BatchAnnotateFilesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p4beta1.ImageAnnotatorClient.batch_annotate_files", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ImageAnnotator", + "rpcName": "BatchAnnotateFiles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchAnnotateImages( @@ -651,7 +825,7 @@ 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_annotator.BatchAnnotateImagesResponse: r"""Call the batch annotate images method over HTTP. @@ -662,8 +836,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_annotator.BatchAnnotateImagesResponse: @@ -675,6 +851,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseBatchAnnotateImages._get_http_options() ) + request, metadata = self._interceptor.pre_batch_annotate_images( request, metadata ) @@ -691,6 +868,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p4beta1.ImageAnnotatorClient.BatchAnnotateImages", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ImageAnnotator", + "rpcName": "BatchAnnotateImages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImageAnnotatorRestTransport._BatchAnnotateImages._get_response( self._host, @@ -712,7 +916,31 @@ def __call__( pb_resp = image_annotator.BatchAnnotateImagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_annotate_images(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + image_annotator.BatchAnnotateImagesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p4beta1.ImageAnnotatorClient.batch_annotate_images", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ImageAnnotator", + "rpcName": "BatchAnnotateImages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/async_client.py b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/async_client.py index 94d731dff25b..640fb1fdca6f 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/async_client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/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, @@ -56,6 +57,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ProductSearchTransport from .transports.grpc_asyncio import ProductSearchGrpcAsyncIOTransport +try: + from google.api_core import client_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 ProductSearchAsyncClient: """Manages Products and ProductSets of reference images for use in @@ -287,6 +297,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.vision_v1p4beta1.ProductSearchAsyncClient`.", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "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.vision.v1p4beta1.ProductSearch", + "credentialsType": None, + }, + ) + async def create_product_set( self, request: Optional[ @@ -298,7 +330,7 @@ async def create_product_set( product_set_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]]] = (), ) -> product_search_service.ProductSet: r"""Creates and returns a new ProductSet resource. @@ -363,8 +395,10 @@ async def sample_create_product_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, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p4beta1.types.ProductSet: @@ -434,7 +468,7 @@ async def list_product_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.ListProductSetsAsyncPager: r"""Lists ProductSets in an unspecified order. @@ -485,8 +519,10 @@ async def sample_list_product_sets(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p4beta1.services.product_search.pagers.ListProductSetsAsyncPager: @@ -562,7 +598,7 @@ async def get_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Gets information associated with a ProductSet. @@ -611,8 +647,10 @@ async def sample_get_product_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, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p4beta1.types.ProductSet: @@ -679,7 +717,7 @@ async def update_product_set( 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]]] = (), ) -> product_search_service.ProductSet: r"""Makes changes to a ProductSet resource. Only display_name can be updated currently. @@ -738,8 +776,10 @@ async def sample_update_product_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, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p4beta1.types.ProductSet: @@ -809,7 +849,7 @@ async def delete_product_set( name: Optional[str] = None, retry: OptionalRetry = 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"""Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. @@ -855,8 +895,10 @@ async def sample_delete_product_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, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -912,7 +954,7 @@ async def create_product( product_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]]] = (), ) -> product_search_service.Product: r"""Creates and returns a new product resource. @@ -981,8 +1023,10 @@ async def sample_create_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.cloud.vision_v1p4beta1.types.Product: @@ -1047,7 +1091,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 products in an unspecified order. @@ -1098,8 +1142,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.cloud.vision_v1p4beta1.services.product_search.pagers.ListProductsAsyncPager: @@ -1173,7 +1219,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]]] = (), ) -> product_search_service.Product: r"""Gets information associated with a Product. @@ -1222,8 +1268,10 @@ 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.cloud.vision_v1p4beta1.types.Product: @@ -1285,7 +1333,7 @@ async def update_product( 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]]] = (), ) -> product_search_service.Product: r"""Makes changes to a Product resource. Only the ``display_name``, ``description``, and ``labels`` fields can be updated right now. @@ -1353,8 +1401,10 @@ async def sample_update_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.cloud.vision_v1p4beta1.types.Product: @@ -1419,7 +1469,7 @@ async def delete_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]]] = (), ) -> None: r"""Permanently deletes a product and its reference images. @@ -1466,8 +1516,10 @@ async def sample_delete_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1523,7 +1575,7 @@ async def create_reference_image( reference_image_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]]] = (), ) -> product_search_service.ReferenceImage: r"""Creates and returns a new ReferenceImage resource. @@ -1612,8 +1664,10 @@ async def sample_create_reference_image(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p4beta1.types.ReferenceImage: @@ -1680,7 +1734,7 @@ async def delete_reference_image( name: Optional[str] = None, retry: OptionalRetry = 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"""Permanently deletes a reference image. @@ -1731,8 +1785,10 @@ async def sample_delete_reference_image(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -1786,7 +1842,7 @@ async def list_reference_images( 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.ListReferenceImagesAsyncPager: r"""Lists reference images. @@ -1839,8 +1895,10 @@ async def sample_list_reference_images(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p4beta1.services.product_search.pagers.ListReferenceImagesAsyncPager: @@ -1916,7 +1974,7 @@ async def get_reference_image( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Gets information associated with a ReferenceImage. @@ -1967,8 +2025,10 @@ async def sample_get_reference_image(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p4beta1.types.ReferenceImage: @@ -2032,7 +2092,7 @@ async def add_product_to_product_set( product: Optional[str] = None, retry: OptionalRetry = 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"""Adds a Product to the specified ProductSet. If the Product is already present, no change is made. @@ -2095,8 +2155,10 @@ async def sample_add_product_to_product_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, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -2155,7 +2217,7 @@ async def remove_product_from_product_set( product: Optional[str] = None, retry: OptionalRetry = 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"""Removes a Product from the specified ProductSet. @@ -2210,8 +2272,10 @@ async def sample_remove_product_from_product_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, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -2269,7 +2333,7 @@ async def list_products_in_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductsInProductSetAsyncPager: r"""Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the @@ -2324,8 +2388,10 @@ async def sample_list_products_in_product_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, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p4beta1.services.product_search.pagers.ListProductsInProductSetAsyncPager: @@ -2407,7 +2473,7 @@ async def import_product_sets( ] = None, retry: OptionalRetry = gapic_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"""Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. @@ -2474,8 +2540,10 @@ async def sample_import_product_sets(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2557,7 +2625,7 @@ async def purge_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]]] = (), ) -> operation_async.AsyncOperation: r"""Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. @@ -2632,8 +2700,10 @@ async def sample_purge_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.api_core.operation_async.AsyncOperation: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/client.py b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/client.py index 804a4f7e52d1..a0cee9ef0d6b 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/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 @@ -651,6 +661,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( @@ -716,6 +730,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.vision_v1p4beta1.ProductSearchClient`.", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "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.vision.v1p4beta1.ProductSearch", + "credentialsType": None, + }, + ) + def create_product_set( self, request: Optional[ @@ -727,7 +764,7 @@ def create_product_set( product_set_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]]] = (), ) -> product_search_service.ProductSet: r"""Creates and returns a new ProductSet resource. @@ -792,8 +829,10 @@ def sample_create_product_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.cloud.vision_v1p4beta1.types.ProductSet: @@ -860,7 +899,7 @@ def list_product_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.ListProductSetsPager: r"""Lists ProductSets in an unspecified order. @@ -911,8 +950,10 @@ def sample_list_product_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.vision_v1p4beta1.services.product_search.pagers.ListProductSetsPager: @@ -985,7 +1026,7 @@ def get_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Gets information associated with a ProductSet. @@ -1034,8 +1075,10 @@ def sample_get_product_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.cloud.vision_v1p4beta1.types.ProductSet: @@ -1099,7 +1142,7 @@ def update_product_set( 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]]] = (), ) -> product_search_service.ProductSet: r"""Makes changes to a ProductSet resource. Only display_name can be updated currently. @@ -1158,8 +1201,10 @@ def sample_update_product_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.cloud.vision_v1p4beta1.types.ProductSet: @@ -1226,7 +1271,7 @@ def delete_product_set( name: Optional[str] = None, retry: OptionalRetry = 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"""Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. @@ -1272,8 +1317,10 @@ def sample_delete_product_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1326,7 +1373,7 @@ def create_product( product_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]]] = (), ) -> product_search_service.Product: r"""Creates and returns a new product resource. @@ -1395,8 +1442,10 @@ def sample_create_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.cloud.vision_v1p4beta1.types.Product: @@ -1458,7 +1507,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 products in an unspecified order. @@ -1509,8 +1558,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.cloud.vision_v1p4beta1.services.product_search.pagers.ListProductsPager: @@ -1581,7 +1632,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]]] = (), ) -> product_search_service.Product: r"""Gets information associated with a Product. @@ -1630,8 +1681,10 @@ 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.cloud.vision_v1p4beta1.types.Product: @@ -1690,7 +1743,7 @@ def update_product( 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]]] = (), ) -> product_search_service.Product: r"""Makes changes to a Product resource. Only the ``display_name``, ``description``, and ``labels`` fields can be updated right now. @@ -1758,8 +1811,10 @@ def sample_update_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.cloud.vision_v1p4beta1.types.Product: @@ -1821,7 +1876,7 @@ def delete_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]]] = (), ) -> None: r"""Permanently deletes a product and its reference images. @@ -1868,8 +1923,10 @@ def sample_delete_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1922,7 +1979,7 @@ def create_reference_image( reference_image_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]]] = (), ) -> product_search_service.ReferenceImage: r"""Creates and returns a new ReferenceImage resource. @@ -2011,8 +2068,10 @@ def sample_create_reference_image(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p4beta1.types.ReferenceImage: @@ -2076,7 +2135,7 @@ def delete_reference_image( name: Optional[str] = None, retry: OptionalRetry = 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"""Permanently deletes a reference image. @@ -2127,8 +2186,10 @@ def sample_delete_reference_image(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -2179,7 +2240,7 @@ def list_reference_images( 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.ListReferenceImagesPager: r"""Lists reference images. @@ -2232,8 +2293,10 @@ def sample_list_reference_images(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p4beta1.services.product_search.pagers.ListReferenceImagesPager: @@ -2306,7 +2369,7 @@ def get_reference_image( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Gets information associated with a ReferenceImage. @@ -2357,8 +2420,10 @@ def sample_get_reference_image(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vision_v1p4beta1.types.ReferenceImage: @@ -2419,7 +2484,7 @@ def add_product_to_product_set( product: Optional[str] = None, retry: OptionalRetry = 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"""Adds a Product to the specified ProductSet. If the Product is already present, no change is made. @@ -2482,8 +2547,10 @@ def sample_add_product_to_product_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2541,7 +2608,7 @@ def remove_product_from_product_set( product: Optional[str] = None, retry: OptionalRetry = 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"""Removes a Product from the specified ProductSet. @@ -2596,8 +2663,10 @@ def sample_remove_product_from_product_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2654,7 +2723,7 @@ def list_products_in_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductsInProductSetPager: r"""Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the @@ -2709,8 +2778,10 @@ def sample_list_products_in_product_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.cloud.vision_v1p4beta1.services.product_search.pagers.ListProductsInProductSetPager: @@ -2791,7 +2862,7 @@ def import_product_sets( ] = None, retry: OptionalRetry = gapic_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"""Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. @@ -2858,8 +2929,10 @@ def sample_import_product_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.api_core.operation.Operation: @@ -2938,7 +3011,7 @@ def purge_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]]] = (), ) -> operation.Operation: r"""Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. @@ -3013,8 +3086,10 @@ def sample_purge_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.api_core.operation.Operation: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/pagers.py b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/pagers.py index ce5b978033b3..b46cbcb43a13 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/pagers.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/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 = product_search_service.ListProductSetsRequest(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 = product_search_service.ListProductSetsRequest(request) @@ -223,7 +227,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -237,8 +241,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = product_search_service.ListProductsRequest(request) @@ -297,7 +303,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. @@ -311,8 +317,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 = product_search_service.ListProductsRequest(request) @@ -375,7 +383,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -389,8 +397,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = product_search_service.ListReferenceImagesRequest(request) @@ -451,7 +461,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. @@ -465,8 +475,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 = product_search_service.ListReferenceImagesRequest(request) @@ -531,7 +543,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -545,8 +557,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = product_search_service.ListProductsInProductSetRequest(request) @@ -609,7 +623,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. @@ -623,8 +637,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 = product_search_service.ListProductsInProductSetRequest(request) diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/transports/grpc.py b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/transports/grpc.py index 3d35ad5603d8..9d911ff400cb 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/transports/grpc.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/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.vision_v1p4beta1.types import product_search_service from .base import DEFAULT_CLIENT_INFO, ProductSearchTransport +try: + from google.api_core import client_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.vision.v1p4beta1.ProductSearch", + "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.vision.v1p4beta1.ProductSearch", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProductSearchGrpcTransport(ProductSearchTransport): """gRPC backend transport for ProductSearch. @@ -201,7 +282,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,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 @@ -297,7 +385,7 @@ def create_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product_set" not in self._stubs: - self._stubs["create_product_set"] = self.grpc_channel.unary_unary( + self._stubs["create_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/CreateProductSet", request_serializer=product_search_service.CreateProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -331,7 +419,7 @@ def list_product_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_product_sets" not in self._stubs: - self._stubs["list_product_sets"] = self.grpc_channel.unary_unary( + self._stubs["list_product_sets"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/ListProductSets", request_serializer=product_search_service.ListProductSetsRequest.serialize, response_deserializer=product_search_service.ListProductSetsResponse.deserialize, @@ -363,7 +451,7 @@ def get_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product_set" not in self._stubs: - self._stubs["get_product_set"] = self.grpc_channel.unary_unary( + self._stubs["get_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/GetProductSet", request_serializer=product_search_service.GetProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -400,7 +488,7 @@ def update_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product_set" not in self._stubs: - self._stubs["update_product_set"] = self.grpc_channel.unary_unary( + self._stubs["update_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/UpdateProductSet", request_serializer=product_search_service.UpdateProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -430,7 +518,7 @@ def delete_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product_set" not in self._stubs: - self._stubs["delete_product_set"] = self.grpc_channel.unary_unary( + self._stubs["delete_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/DeleteProductSet", request_serializer=product_search_service.DeleteProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -467,7 +555,7 @@ def create_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product" not in self._stubs: - self._stubs["create_product"] = self.grpc_channel.unary_unary( + self._stubs["create_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/CreateProduct", request_serializer=product_search_service.CreateProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -501,7 +589,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.cloud.vision.v1p4beta1.ProductSearch/ListProducts", request_serializer=product_search_service.ListProductsRequest.serialize, response_deserializer=product_search_service.ListProductsResponse.deserialize, @@ -533,7 +621,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.cloud.vision.v1p4beta1.ProductSearch/GetProduct", request_serializer=product_search_service.GetProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -576,7 +664,7 @@ def update_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product" not in self._stubs: - self._stubs["update_product"] = self.grpc_channel.unary_unary( + self._stubs["update_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/UpdateProduct", request_serializer=product_search_service.UpdateProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -607,7 +695,7 @@ def delete_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product" not in self._stubs: - self._stubs["delete_product"] = self.grpc_channel.unary_unary( + self._stubs["delete_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/DeleteProduct", request_serializer=product_search_service.DeleteProductRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -657,7 +745,7 @@ def create_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_reference_image" not in self._stubs: - self._stubs["create_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["create_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/CreateReferenceImage", request_serializer=product_search_service.CreateReferenceImageRequest.serialize, response_deserializer=product_search_service.ReferenceImage.deserialize, @@ -692,7 +780,7 @@ def delete_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_reference_image" not in self._stubs: - self._stubs["delete_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["delete_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/DeleteReferenceImage", request_serializer=product_search_service.DeleteReferenceImageRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -727,7 +815,7 @@ def list_reference_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_reference_images" not in self._stubs: - self._stubs["list_reference_images"] = self.grpc_channel.unary_unary( + self._stubs["list_reference_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/ListReferenceImages", request_serializer=product_search_service.ListReferenceImagesRequest.serialize, response_deserializer=product_search_service.ListReferenceImagesResponse.deserialize, @@ -760,7 +848,7 @@ def get_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_reference_image" not in self._stubs: - self._stubs["get_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["get_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/GetReferenceImage", request_serializer=product_search_service.GetReferenceImageRequest.serialize, response_deserializer=product_search_service.ReferenceImage.deserialize, @@ -796,7 +884,9 @@ def add_product_to_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_product_to_product_set" not in self._stubs: - self._stubs["add_product_to_product_set"] = self.grpc_channel.unary_unary( + self._stubs[ + "add_product_to_product_set" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/AddProductToProductSet", request_serializer=product_search_service.AddProductToProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -827,7 +917,7 @@ def remove_product_from_product_set( if "remove_product_from_product_set" not in self._stubs: self._stubs[ "remove_product_from_product_set" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/RemoveProductFromProductSet", request_serializer=product_search_service.RemoveProductFromProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -863,7 +953,9 @@ def list_products_in_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products_in_product_set" not in self._stubs: - self._stubs["list_products_in_product_set"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_products_in_product_set" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/ListProductsInProductSet", request_serializer=product_search_service.ListProductsInProductSetRequest.serialize, response_deserializer=product_search_service.ListProductsInProductSetResponse.deserialize, @@ -902,7 +994,7 @@ def import_product_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_product_sets" not in self._stubs: - self._stubs["import_product_sets"] = self.grpc_channel.unary_unary( + self._stubs["import_product_sets"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/ImportProductSets", request_serializer=product_search_service.ImportProductSetsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -956,7 +1048,7 @@ def purge_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_products" not in self._stubs: - self._stubs["purge_products"] = self.grpc_channel.unary_unary( + self._stubs["purge_products"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/PurgeProducts", request_serializer=product_search_service.PurgeProductsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -964,7 +1056,7 @@ def purge_products( return self._stubs["purge_products"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/transports/grpc_asyncio.py b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/transports/grpc_asyncio.py index f0aad5b7ea14..36eeddf047cd 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/transports/grpc_asyncio.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/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.vision_v1p4beta1.types import product_search_service from .base import DEFAULT_CLIENT_INFO, ProductSearchTransport from .grpc import ProductSearchGrpcTransport +try: + from google.api_core import client_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.vision.v1p4beta1.ProductSearch", + "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.vision.v1p4beta1.ProductSearch", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProductSearchGrpcAsyncIOTransport(ProductSearchTransport): """gRPC AsyncIO backend transport for ProductSearch. @@ -248,10 +330,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 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. @@ -307,7 +392,7 @@ def create_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product_set" not in self._stubs: - self._stubs["create_product_set"] = self.grpc_channel.unary_unary( + self._stubs["create_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/CreateProductSet", request_serializer=product_search_service.CreateProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -341,7 +426,7 @@ def list_product_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_product_sets" not in self._stubs: - self._stubs["list_product_sets"] = self.grpc_channel.unary_unary( + self._stubs["list_product_sets"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/ListProductSets", request_serializer=product_search_service.ListProductSetsRequest.serialize, response_deserializer=product_search_service.ListProductSetsResponse.deserialize, @@ -374,7 +459,7 @@ def get_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product_set" not in self._stubs: - self._stubs["get_product_set"] = self.grpc_channel.unary_unary( + self._stubs["get_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/GetProductSet", request_serializer=product_search_service.GetProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -411,7 +496,7 @@ def update_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product_set" not in self._stubs: - self._stubs["update_product_set"] = self.grpc_channel.unary_unary( + self._stubs["update_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/UpdateProductSet", request_serializer=product_search_service.UpdateProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -443,7 +528,7 @@ def delete_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product_set" not in self._stubs: - self._stubs["delete_product_set"] = self.grpc_channel.unary_unary( + self._stubs["delete_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/DeleteProductSet", request_serializer=product_search_service.DeleteProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -481,7 +566,7 @@ def create_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product" not in self._stubs: - self._stubs["create_product"] = self.grpc_channel.unary_unary( + self._stubs["create_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/CreateProduct", request_serializer=product_search_service.CreateProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -515,7 +600,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.cloud.vision.v1p4beta1.ProductSearch/ListProducts", request_serializer=product_search_service.ListProductsRequest.serialize, response_deserializer=product_search_service.ListProductsResponse.deserialize, @@ -548,7 +633,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.cloud.vision.v1p4beta1.ProductSearch/GetProduct", request_serializer=product_search_service.GetProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -592,7 +677,7 @@ def update_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product" not in self._stubs: - self._stubs["update_product"] = self.grpc_channel.unary_unary( + self._stubs["update_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/UpdateProduct", request_serializer=product_search_service.UpdateProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -625,7 +710,7 @@ def delete_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product" not in self._stubs: - self._stubs["delete_product"] = self.grpc_channel.unary_unary( + self._stubs["delete_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/DeleteProduct", request_serializer=product_search_service.DeleteProductRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -675,7 +760,7 @@ def create_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_reference_image" not in self._stubs: - self._stubs["create_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["create_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/CreateReferenceImage", request_serializer=product_search_service.CreateReferenceImageRequest.serialize, response_deserializer=product_search_service.ReferenceImage.deserialize, @@ -710,7 +795,7 @@ def delete_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_reference_image" not in self._stubs: - self._stubs["delete_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["delete_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/DeleteReferenceImage", request_serializer=product_search_service.DeleteReferenceImageRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -745,7 +830,7 @@ def list_reference_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_reference_images" not in self._stubs: - self._stubs["list_reference_images"] = self.grpc_channel.unary_unary( + self._stubs["list_reference_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/ListReferenceImages", request_serializer=product_search_service.ListReferenceImagesRequest.serialize, response_deserializer=product_search_service.ListReferenceImagesResponse.deserialize, @@ -778,7 +863,7 @@ def get_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_reference_image" not in self._stubs: - self._stubs["get_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["get_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/GetReferenceImage", request_serializer=product_search_service.GetReferenceImageRequest.serialize, response_deserializer=product_search_service.ReferenceImage.deserialize, @@ -815,7 +900,9 @@ def add_product_to_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_product_to_product_set" not in self._stubs: - self._stubs["add_product_to_product_set"] = self.grpc_channel.unary_unary( + self._stubs[ + "add_product_to_product_set" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/AddProductToProductSet", request_serializer=product_search_service.AddProductToProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -847,7 +934,7 @@ def remove_product_from_product_set( if "remove_product_from_product_set" not in self._stubs: self._stubs[ "remove_product_from_product_set" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/RemoveProductFromProductSet", request_serializer=product_search_service.RemoveProductFromProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -883,7 +970,9 @@ def list_products_in_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products_in_product_set" not in self._stubs: - self._stubs["list_products_in_product_set"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_products_in_product_set" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/ListProductsInProductSet", request_serializer=product_search_service.ListProductsInProductSetRequest.serialize, response_deserializer=product_search_service.ListProductsInProductSetResponse.deserialize, @@ -923,7 +1012,7 @@ def import_product_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_product_sets" not in self._stubs: - self._stubs["import_product_sets"] = self.grpc_channel.unary_unary( + self._stubs["import_product_sets"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/ImportProductSets", request_serializer=product_search_service.ImportProductSetsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -978,7 +1067,7 @@ def purge_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_products" not in self._stubs: - self._stubs["purge_products"] = self.grpc_channel.unary_unary( + self._stubs["purge_products"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/PurgeProducts", request_serializer=product_search_service.PurgeProductsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1247,7 +1336,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-vision/google/cloud/vision_v1p4beta1/services/product_search/transports/rest.py b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/transports/rest.py index efa44e5bd1c7..3c4c6b3bb5b8 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/transports/rest.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/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, @@ -203,9 +211,10 @@ def post_update_product_set(self, response): def pre_add_product_to_product_set( self, request: product_search_service.AddProductToProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.AddProductToProductSetRequest, Sequence[Tuple[str, str]] + product_search_service.AddProductToProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for add_product_to_product_set @@ -217,8 +226,11 @@ def pre_add_product_to_product_set( def pre_create_product( self, request: product_search_service.CreateProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.CreateProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.CreateProductRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_product Override in a subclass to manipulate the request or metadata @@ -240,9 +252,10 @@ def post_create_product( def pre_create_product_set( self, request: product_search_service.CreateProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.CreateProductSetRequest, Sequence[Tuple[str, str]] + product_search_service.CreateProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_product_set @@ -265,9 +278,10 @@ def post_create_product_set( def pre_create_reference_image( self, request: product_search_service.CreateReferenceImageRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.CreateReferenceImageRequest, Sequence[Tuple[str, str]] + product_search_service.CreateReferenceImageRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_reference_image @@ -290,8 +304,11 @@ def post_create_reference_image( def pre_delete_product( self, request: product_search_service.DeleteProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.DeleteProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.DeleteProductRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_product Override in a subclass to manipulate the request or metadata @@ -302,9 +319,10 @@ def pre_delete_product( def pre_delete_product_set( self, request: product_search_service.DeleteProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.DeleteProductSetRequest, Sequence[Tuple[str, str]] + product_search_service.DeleteProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_product_set @@ -316,9 +334,10 @@ def pre_delete_product_set( def pre_delete_reference_image( self, request: product_search_service.DeleteReferenceImageRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.DeleteReferenceImageRequest, Sequence[Tuple[str, str]] + product_search_service.DeleteReferenceImageRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_reference_image @@ -330,8 +349,11 @@ def pre_delete_reference_image( def pre_get_product( self, request: product_search_service.GetProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.GetProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.GetProductRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_product Override in a subclass to manipulate the request or metadata @@ -353,8 +375,11 @@ def post_get_product( def pre_get_product_set( self, request: product_search_service.GetProductSetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.GetProductSetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.GetProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_product_set Override in a subclass to manipulate the request or metadata @@ -376,9 +401,10 @@ def post_get_product_set( def pre_get_reference_image( self, request: product_search_service.GetReferenceImageRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.GetReferenceImageRequest, Sequence[Tuple[str, str]] + product_search_service.GetReferenceImageRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_reference_image @@ -401,9 +427,10 @@ def post_get_reference_image( def pre_import_product_sets( self, request: product_search_service.ImportProductSetsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.ImportProductSetsRequest, Sequence[Tuple[str, str]] + product_search_service.ImportProductSetsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for import_product_sets @@ -426,8 +453,11 @@ def post_import_product_sets( def pre_list_products( self, request: product_search_service.ListProductsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.ListProductsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.ListProductsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_products Override in a subclass to manipulate the request or metadata @@ -449,9 +479,10 @@ def post_list_products( def pre_list_product_sets( self, request: product_search_service.ListProductSetsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.ListProductSetsRequest, Sequence[Tuple[str, str]] + product_search_service.ListProductSetsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_product_sets @@ -474,10 +505,10 @@ def post_list_product_sets( def pre_list_products_in_product_set( self, request: product_search_service.ListProductsInProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ product_search_service.ListProductsInProductSetRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_products_in_product_set @@ -500,9 +531,10 @@ def post_list_products_in_product_set( def pre_list_reference_images( self, request: product_search_service.ListReferenceImagesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.ListReferenceImagesRequest, Sequence[Tuple[str, str]] + product_search_service.ListReferenceImagesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_reference_images @@ -525,8 +557,11 @@ def post_list_reference_images( def pre_purge_products( self, request: product_search_service.PurgeProductsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.PurgeProductsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.PurgeProductsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for purge_products Override in a subclass to manipulate the request or metadata @@ -548,10 +583,10 @@ def post_purge_products( def pre_remove_product_from_product_set( self, request: product_search_service.RemoveProductFromProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ product_search_service.RemoveProductFromProductSetRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for remove_product_from_product_set @@ -563,8 +598,11 @@ def pre_remove_product_from_product_set( def pre_update_product( self, request: product_search_service.UpdateProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.UpdateProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.UpdateProductRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_product Override in a subclass to manipulate the request or metadata @@ -586,9 +624,10 @@ def post_update_product( def pre_update_product_set( self, request: product_search_service.UpdateProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.UpdateProductSetRequest, Sequence[Tuple[str, str]] + product_search_service.UpdateProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_product_set @@ -778,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 add product to product set method over HTTP. @@ -790,13 +829,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 = ( _BaseProductSearchRestTransport._BaseAddProductToProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_add_product_to_product_set( request, metadata ) @@ -813,6 +855,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p4beta1.ProductSearchClient.AddProductToProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "AddProductToProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._AddProductToProductSet._get_response( self._host, @@ -864,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]]] = (), ) -> product_search_service.Product: r"""Call the create product method over HTTP. @@ -874,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: ~.product_search_service.Product: @@ -885,6 +956,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseCreateProduct._get_http_options() ) + request, metadata = self._interceptor.pre_create_product(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseCreateProduct._get_transcoded_request( http_options, request @@ -899,6 +971,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p4beta1.ProductSearchClient.CreateProduct", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "CreateProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._CreateProduct._get_response( self._host, @@ -920,7 +1019,29 @@ def __call__( pb_resp = product_search_service.Product.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.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.cloud.vision_v1p4beta1.ProductSearchClient.create_product", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "CreateProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateProductSet( @@ -958,7 +1079,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Call the create product set method over HTTP. @@ -968,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: ~.product_search_service.ProductSet: @@ -984,6 +1107,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseCreateProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_create_product_set( request, metadata ) @@ -1000,6 +1124,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p4beta1.ProductSearchClient.CreateProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "CreateProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._CreateProductSet._get_response( self._host, @@ -1021,7 +1172,31 @@ def __call__( pb_resp = product_search_service.ProductSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_product_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ProductSet.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p4beta1.ProductSearchClient.create_product_set", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "CreateProductSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateReferenceImage( @@ -1059,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]]] = (), ) -> product_search_service.ReferenceImage: r"""Call the create reference image method over HTTP. @@ -1069,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: ~.product_search_service.ReferenceImage: @@ -1082,6 +1259,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseCreateReferenceImage._get_http_options() ) + request, metadata = self._interceptor.pre_create_reference_image( request, metadata ) @@ -1098,6 +1276,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p4beta1.ProductSearchClient.CreateReferenceImage", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "CreateReferenceImage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._CreateReferenceImage._get_response( self._host, @@ -1119,7 +1324,31 @@ def __call__( pb_resp = product_search_service.ReferenceImage.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_reference_image(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ReferenceImage.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p4beta1.ProductSearchClient.create_reference_image", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "CreateReferenceImage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteProduct( @@ -1156,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]]] = (), ): r"""Call the delete product method over HTTP. @@ -1166,13 +1395,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 = ( _BaseProductSearchRestTransport._BaseDeleteProduct._get_http_options() ) + request, metadata = self._interceptor.pre_delete_product(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseDeleteProduct._get_transcoded_request( http_options, request @@ -1183,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p4beta1.ProductSearchClient.DeleteProduct", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "DeleteProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._DeleteProduct._get_response( self._host, @@ -1232,7 +1491,7 @@ 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 set method over HTTP. @@ -1242,13 +1501,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 = ( _BaseProductSearchRestTransport._BaseDeleteProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_delete_product_set( request, metadata ) @@ -1261,6 +1523,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p4beta1.ProductSearchClient.DeleteProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "DeleteProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._DeleteProductSet._get_response( self._host, @@ -1310,7 +1599,7 @@ 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 reference image method over HTTP. @@ -1320,13 +1609,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 = ( _BaseProductSearchRestTransport._BaseDeleteReferenceImage._get_http_options() ) + request, metadata = self._interceptor.pre_delete_reference_image( request, metadata ) @@ -1339,6 +1631,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p4beta1.ProductSearchClient.DeleteReferenceImage", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "DeleteReferenceImage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._DeleteReferenceImage._get_response( self._host, @@ -1388,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]]] = (), ) -> product_search_service.Product: r"""Call the get product method over HTTP. @@ -1398,8 +1717,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.product_search_service.Product: @@ -1409,6 +1730,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseGetProduct._get_http_options() ) + request, metadata = self._interceptor.pre_get_product(request, metadata) transcoded_request = ( _BaseProductSearchRestTransport._BaseGetProduct._get_transcoded_request( @@ -1423,6 +1745,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p4beta1.ProductSearchClient.GetProduct", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "GetProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._GetProduct._get_response( self._host, @@ -1443,7 +1792,29 @@ def __call__( pb_resp = product_search_service.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 = product_search_service.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.cloud.vision_v1p4beta1.ProductSearchClient.get_product", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "GetProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetProductSet( @@ -1480,7 +1851,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Call the get product set method over HTTP. @@ -1490,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: ~.product_search_service.ProductSet: @@ -1506,6 +1879,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseGetProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_get_product_set(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseGetProductSet._get_transcoded_request( http_options, request @@ -1516,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.vision_v1p4beta1.ProductSearchClient.GetProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "GetProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._GetProductSet._get_response( self._host, @@ -1536,7 +1937,31 @@ def __call__( pb_resp = product_search_service.ProductSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_product_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ProductSet.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p4beta1.ProductSearchClient.get_product_set", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "GetProductSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetReferenceImage( @@ -1573,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]]] = (), ) -> product_search_service.ReferenceImage: r"""Call the get reference image method over HTTP. @@ -1583,8 +2008,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.product_search_service.ReferenceImage: @@ -1596,6 +2023,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseGetReferenceImage._get_http_options() ) + request, metadata = self._interceptor.pre_get_reference_image( request, metadata ) @@ -1608,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.vision_v1p4beta1.ProductSearchClient.GetReferenceImage", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "GetReferenceImage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._GetReferenceImage._get_response( self._host, @@ -1628,7 +2083,31 @@ def __call__( pb_resp = product_search_service.ReferenceImage.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_reference_image(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ReferenceImage.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p4beta1.ProductSearchClient.get_reference_image", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "GetReferenceImage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportProductSets( @@ -1666,7 +2145,7 @@ 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 product sets method over HTTP. @@ -1676,8 +2155,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1690,6 +2171,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseImportProductSets._get_http_options() ) + request, metadata = self._interceptor.pre_import_product_sets( request, metadata ) @@ -1706,6 +2188,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p4beta1.ProductSearchClient.ImportProductSets", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "ImportProductSets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._ImportProductSets._get_response( self._host, @@ -1725,7 +2234,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_product_sets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p4beta1.ProductSearchClient.import_product_sets", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "ImportProductSets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProducts( @@ -1762,7 +2293,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ListProductsResponse: r"""Call the list products method over HTTP. @@ -1772,8 +2303,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.product_search_service.ListProductsResponse: @@ -1783,6 +2316,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseListProducts._get_http_options() ) + request, metadata = self._interceptor.pre_list_products(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseListProducts._get_transcoded_request( http_options, request @@ -1793,6 +2327,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p4beta1.ProductSearchClient.ListProducts", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "ListProducts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._ListProducts._get_response( self._host, @@ -1813,7 +2374,31 @@ def __call__( pb_resp = product_search_service.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 = ( + product_search_service.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.cloud.vision_v1p4beta1.ProductSearchClient.list_products", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "ListProducts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProductSets( @@ -1850,7 +2435,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ListProductSetsResponse: r"""Call the list product sets method over HTTP. @@ -1860,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: ~.product_search_service.ListProductSetsResponse: @@ -1871,6 +2458,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseListProductSets._get_http_options() ) + request, metadata = self._interceptor.pre_list_product_sets( request, metadata ) @@ -1883,6 +2471,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p4beta1.ProductSearchClient.ListProductSets", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "ListProductSets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._ListProductSets._get_response( self._host, @@ -1903,7 +2518,31 @@ def __call__( pb_resp = product_search_service.ListProductSetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_product_sets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + product_search_service.ListProductSetsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p4beta1.ProductSearchClient.list_product_sets", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "ListProductSets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProductsInProductSet( @@ -1941,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]]] = (), ) -> product_search_service.ListProductsInProductSetResponse: r"""Call the list products in product set method over HTTP. @@ -1953,8 +2592,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.product_search_service.ListProductsInProductSetResponse: @@ -1966,6 +2607,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseListProductsInProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_list_products_in_product_set( request, metadata ) @@ -1978,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.vision_v1p4beta1.ProductSearchClient.ListProductsInProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "ListProductsInProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ProductSearchRestTransport._ListProductsInProductSet._get_response( @@ -2000,7 +2669,33 @@ def __call__( pb_resp = product_search_service.ListProductsInProductSetResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_products_in_product_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + product_search_service.ListProductsInProductSetResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p4beta1.ProductSearchClient.list_products_in_product_set", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "ListProductsInProductSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListReferenceImages( @@ -2037,7 +2732,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ListReferenceImagesResponse: r"""Call the list reference images method over HTTP. @@ -2047,8 +2742,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.product_search_service.ListReferenceImagesResponse: @@ -2058,6 +2755,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseListReferenceImages._get_http_options() ) + request, metadata = self._interceptor.pre_list_reference_images( request, metadata ) @@ -2070,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.vision_v1p4beta1.ProductSearchClient.ListReferenceImages", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "ListReferenceImages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._ListReferenceImages._get_response( self._host, @@ -2090,7 +2815,33 @@ def __call__( pb_resp = product_search_service.ListReferenceImagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_reference_images(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + product_search_service.ListReferenceImagesResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p4beta1.ProductSearchClient.list_reference_images", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "ListReferenceImages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PurgeProducts( @@ -2128,7 +2879,7 @@ 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 purge products method over HTTP. @@ -2138,8 +2889,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2152,6 +2905,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BasePurgeProducts._get_http_options() ) + request, metadata = self._interceptor.pre_purge_products(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BasePurgeProducts._get_transcoded_request( http_options, request @@ -2166,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.vision_v1p4beta1.ProductSearchClient.PurgeProducts", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "PurgeProducts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._PurgeProducts._get_response( self._host, @@ -2185,7 +2966,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_purge_products(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p4beta1.ProductSearchClient.purge_products", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "PurgeProducts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveProductFromProductSet( @@ -2224,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]]] = (), ): r"""Call the remove product from product set method over HTTP. @@ -2236,13 +3039,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 = ( _BaseProductSearchRestTransport._BaseRemoveProductFromProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_remove_product_from_product_set( request, metadata ) @@ -2259,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p4beta1.ProductSearchClient.RemoveProductFromProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "RemoveProductFromProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ProductSearchRestTransport._RemoveProductFromProductSet._get_response( @@ -2312,7 +3145,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Call the update product method over HTTP. @@ -2322,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: ~.product_search_service.Product: @@ -2333,6 +3168,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseUpdateProduct._get_http_options() ) + request, metadata = self._interceptor.pre_update_product(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseUpdateProduct._get_transcoded_request( http_options, request @@ -2347,6 +3183,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p4beta1.ProductSearchClient.UpdateProduct", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "UpdateProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._UpdateProduct._get_response( self._host, @@ -2368,7 +3231,29 @@ def __call__( pb_resp = product_search_service.Product.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.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.cloud.vision_v1p4beta1.ProductSearchClient.update_product", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "UpdateProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateProductSet( @@ -2406,7 +3291,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Call the update product set method over HTTP. @@ -2416,8 +3301,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.product_search_service.ProductSet: @@ -2432,6 +3319,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseUpdateProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_update_product_set( request, metadata ) @@ -2448,6 +3336,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vision_v1p4beta1.ProductSearchClient.UpdateProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "UpdateProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._UpdateProductSet._get_response( self._host, @@ -2469,7 +3384,31 @@ def __call__( pb_resp = product_search_service.ProductSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_product_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ProductSet.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vision_v1p4beta1.ProductSearchClient.update_product_set", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "UpdateProductSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1.json b/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1.json index eb9273fbcb25..8508099e5ba2 100644 --- a/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1.json +++ b/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-vision", - "version": "3.8.1" + "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", @@ -212,7 +212,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -377,7 +377,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.BatchAnnotateFilesResponse", @@ -457,7 +457,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.BatchAnnotateFilesResponse", @@ -538,7 +538,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.BatchAnnotateImagesResponse", @@ -618,7 +618,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.BatchAnnotateImagesResponse", @@ -703,7 +703,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "add_product_to_product_set" @@ -784,7 +784,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "add_product_to_product_set" @@ -870,7 +870,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.ProductSet", @@ -958,7 +958,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.ProductSet", @@ -1047,7 +1047,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.Product", @@ -1135,7 +1135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.Product", @@ -1224,7 +1224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.ReferenceImage", @@ -1312,7 +1312,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.ReferenceImage", @@ -1393,7 +1393,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product_set" @@ -1470,7 +1470,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product_set" @@ -1548,7 +1548,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product" @@ -1625,7 +1625,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product" @@ -1703,7 +1703,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_reference_image" @@ -1780,7 +1780,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_reference_image" @@ -1858,7 +1858,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.ProductSet", @@ -1938,7 +1938,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.ProductSet", @@ -2019,7 +2019,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.Product", @@ -2099,7 +2099,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.Product", @@ -2180,7 +2180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.ReferenceImage", @@ -2260,7 +2260,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.ReferenceImage", @@ -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.vision_v1.services.product_search.pagers.ListProductSetsAsyncPager", @@ -2590,7 +2590,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.services.product_search.pagers.ListProductSetsPager", @@ -2671,7 +2671,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.services.product_search.pagers.ListProductsInProductSetAsyncPager", @@ -2751,7 +2751,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.services.product_search.pagers.ListProductsInProductSetPager", @@ -2832,7 +2832,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.services.product_search.pagers.ListProductsAsyncPager", @@ -2912,7 +2912,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.services.product_search.pagers.ListProductsPager", @@ -2993,7 +2993,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.services.product_search.pagers.ListReferenceImagesAsyncPager", @@ -3073,7 +3073,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.services.product_search.pagers.ListReferenceImagesPager", @@ -3154,7 +3154,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3234,7 +3234,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3319,7 +3319,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "remove_product_from_product_set" @@ -3400,7 +3400,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "remove_product_from_product_set" @@ -3482,7 +3482,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.ProductSet", @@ -3566,7 +3566,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.ProductSet", @@ -3651,7 +3651,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.Product", @@ -3735,7 +3735,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.Product", diff --git a/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p1beta1.json b/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p1beta1.json index bc393f84f224..3274884f3da9 100644 --- a/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p1beta1.json +++ b/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-vision", - "version": "3.8.1" + "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.cloud.vision_v1p1beta1.types.BatchAnnotateImagesResponse", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p1beta1.types.BatchAnnotateImagesResponse", diff --git a/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p2beta1.json b/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p2beta1.json index d5658bd403b8..1737a0ce6698 100644 --- a/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p2beta1.json +++ b/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p2beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-vision", - "version": "3.8.1" + "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.cloud.vision_v1p2beta1.types.BatchAnnotateImagesResponse", @@ -288,7 +288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p2beta1.types.BatchAnnotateImagesResponse", diff --git a/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p3beta1.json b/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p3beta1.json index 076255146208..da3759f8bc75 100644 --- a/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p3beta1.json +++ b/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p3beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-vision", - "version": "3.8.1" + "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.cloud.vision_v1p3beta1.types.BatchAnnotateImagesResponse", @@ -288,7 +288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.BatchAnnotateImagesResponse", @@ -373,7 +373,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "add_product_to_product_set" @@ -454,7 +454,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "add_product_to_product_set" @@ -540,7 +540,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.ProductSet", @@ -628,7 +628,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.ProductSet", @@ -717,7 +717,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.Product", @@ -805,7 +805,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.Product", @@ -894,7 +894,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.ReferenceImage", @@ -982,7 +982,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.ReferenceImage", @@ -1063,7 +1063,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product_set" @@ -1140,7 +1140,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product_set" @@ -1218,7 +1218,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product" @@ -1295,7 +1295,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product" @@ -1373,7 +1373,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_reference_image" @@ -1450,7 +1450,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_reference_image" @@ -1528,7 +1528,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.ProductSet", @@ -1608,7 +1608,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.ProductSet", @@ -1689,7 +1689,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.Product", @@ -1769,7 +1769,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.Product", @@ -1850,7 +1850,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.ReferenceImage", @@ -1930,7 +1930,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.ReferenceImage", @@ -2015,7 +2015,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2099,7 +2099,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2180,7 +2180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.services.product_search.pagers.ListProductSetsAsyncPager", @@ -2260,7 +2260,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.services.product_search.pagers.ListProductSetsPager", @@ -2341,7 +2341,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.services.product_search.pagers.ListProductsInProductSetAsyncPager", @@ -2421,7 +2421,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.services.product_search.pagers.ListProductsInProductSetPager", @@ -2502,7 +2502,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.services.product_search.pagers.ListProductsAsyncPager", @@ -2582,7 +2582,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.services.product_search.pagers.ListProductsPager", @@ -2663,7 +2663,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.services.product_search.pagers.ListReferenceImagesAsyncPager", @@ -2743,7 +2743,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.services.product_search.pagers.ListReferenceImagesPager", @@ -2828,7 +2828,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "remove_product_from_product_set" @@ -2909,7 +2909,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "remove_product_from_product_set" @@ -2991,7 +2991,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.ProductSet", @@ -3075,7 +3075,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.ProductSet", @@ -3160,7 +3160,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.Product", @@ -3244,7 +3244,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.Product", diff --git a/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p4beta1.json b/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p4beta1.json index dadadbdda95c..e239e7f4ae0e 100644 --- a/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p4beta1.json +++ b/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p4beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-vision", - "version": "3.8.1" + "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", @@ -212,7 +212,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -377,7 +377,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.BatchAnnotateFilesResponse", @@ -457,7 +457,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.BatchAnnotateFilesResponse", @@ -538,7 +538,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.BatchAnnotateImagesResponse", @@ -618,7 +618,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.BatchAnnotateImagesResponse", @@ -703,7 +703,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "add_product_to_product_set" @@ -784,7 +784,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "add_product_to_product_set" @@ -870,7 +870,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.ProductSet", @@ -958,7 +958,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.ProductSet", @@ -1047,7 +1047,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.Product", @@ -1135,7 +1135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.Product", @@ -1224,7 +1224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.ReferenceImage", @@ -1312,7 +1312,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.ReferenceImage", @@ -1393,7 +1393,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product_set" @@ -1470,7 +1470,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product_set" @@ -1548,7 +1548,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product" @@ -1625,7 +1625,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product" @@ -1703,7 +1703,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_reference_image" @@ -1780,7 +1780,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_reference_image" @@ -1858,7 +1858,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.ProductSet", @@ -1938,7 +1938,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.ProductSet", @@ -2019,7 +2019,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.Product", @@ -2099,7 +2099,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.Product", @@ -2180,7 +2180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.ReferenceImage", @@ -2260,7 +2260,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.ReferenceImage", @@ -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.vision_v1p4beta1.services.product_search.pagers.ListProductSetsAsyncPager", @@ -2590,7 +2590,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.services.product_search.pagers.ListProductSetsPager", @@ -2671,7 +2671,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.services.product_search.pagers.ListProductsInProductSetAsyncPager", @@ -2751,7 +2751,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.services.product_search.pagers.ListProductsInProductSetPager", @@ -2832,7 +2832,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.services.product_search.pagers.ListProductsAsyncPager", @@ -2912,7 +2912,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.services.product_search.pagers.ListProductsPager", @@ -2993,7 +2993,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.services.product_search.pagers.ListReferenceImagesAsyncPager", @@ -3073,7 +3073,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.services.product_search.pagers.ListReferenceImagesPager", @@ -3154,7 +3154,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3234,7 +3234,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3319,7 +3319,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "remove_product_from_product_set" @@ -3400,7 +3400,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "remove_product_from_product_set" @@ -3482,7 +3482,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.ProductSet", @@ -3566,7 +3566,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.ProductSet", @@ -3651,7 +3651,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.Product", @@ -3735,7 +3735,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.Product", diff --git a/packages/google-cloud-vision/tests/unit/gapic/vision_v1/test_image_annotator.py b/packages/google-cloud-vision/tests/unit/gapic/vision_v1/test_image_annotator.py index 0f3b214297e6..9e386afc3818 100644 --- a/packages/google-cloud-vision/tests/unit/gapic/vision_v1/test_image_annotator.py +++ b/packages/google-cloud-vision/tests/unit/gapic/vision_v1/test_image_annotator.py @@ -2425,6 +2425,7 @@ def test_batch_annotate_images_rest_required_fields( response_value._content = json_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_annotate_images(request) @@ -2474,6 +2475,7 @@ def test_batch_annotate_images_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_annotate_images(**mock_args) @@ -2607,6 +2609,7 @@ def test_batch_annotate_files_rest_required_fields( response_value._content = json_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_annotate_files(request) @@ -2658,6 +2661,7 @@ def test_batch_annotate_files_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_annotate_files(**mock_args) @@ -2795,6 +2799,7 @@ def test_async_batch_annotate_images_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.async_batch_annotate_images(request) @@ -2853,6 +2858,7 @@ def test_async_batch_annotate_images_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.async_batch_annotate_images(**mock_args) @@ -2991,6 +2997,7 @@ def test_async_batch_annotate_files_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.async_batch_annotate_files(request) @@ -3040,6 +3047,7 @@ def test_async_batch_annotate_files_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.async_batch_annotate_files(**mock_args) @@ -3421,6 +3429,7 @@ def test_batch_annotate_images_rest_bad_request( response_value.status_code = 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_annotate_images(request) @@ -3454,6 +3463,7 @@ def test_batch_annotate_images_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_annotate_images(request) # Establish that the response is the type that we expect. @@ -3493,6 +3503,7 @@ def test_batch_annotate_images_rest_interceptors(null_interceptor): req.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_annotator.BatchAnnotateImagesResponse.to_json( image_annotator.BatchAnnotateImagesResponse() ) @@ -3539,6 +3550,7 @@ def test_batch_annotate_files_rest_bad_request( response_value.status_code = 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_annotate_files(request) @@ -3572,6 +3584,7 @@ def test_batch_annotate_files_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_annotate_files(request) # Establish that the response is the type that we expect. @@ -3611,6 +3624,7 @@ def test_batch_annotate_files_rest_interceptors(null_interceptor): req.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_annotator.BatchAnnotateFilesResponse.to_json( image_annotator.BatchAnnotateFilesResponse() ) @@ -3657,6 +3671,7 @@ def test_async_batch_annotate_images_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.async_batch_annotate_images(request) @@ -3687,6 +3702,7 @@ def test_async_batch_annotate_images_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.async_batch_annotate_images(request) # Establish that the response is the type that we expect. @@ -3728,6 +3744,7 @@ def test_async_batch_annotate_images_rest_interceptors(null_interceptor): req.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 @@ -3772,6 +3789,7 @@ def test_async_batch_annotate_files_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.async_batch_annotate_files(request) @@ -3802,6 +3820,7 @@ def test_async_batch_annotate_files_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.async_batch_annotate_files(request) # Establish that the response is the type that we expect. @@ -3843,6 +3862,7 @@ def test_async_batch_annotate_files_rest_interceptors(null_interceptor): req.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 @@ -3889,6 +3909,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) @@ -3919,6 +3940,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) diff --git a/packages/google-cloud-vision/tests/unit/gapic/vision_v1/test_product_search.py b/packages/google-cloud-vision/tests/unit/gapic/vision_v1/test_product_search.py index 321cdcd137b2..1287f1cb8b0d 100644 --- a/packages/google-cloud-vision/tests/unit/gapic/vision_v1/test_product_search.py +++ b/packages/google-cloud-vision/tests/unit/gapic/vision_v1/test_product_search.py @@ -8517,6 +8517,7 @@ def test_create_product_set_rest_required_fields( response_value._content = json_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_product_set(request) @@ -8572,6 +8573,7 @@ def test_create_product_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_product_set(**mock_args) @@ -8716,6 +8718,7 @@ def test_list_product_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_product_sets(request) @@ -8769,6 +8772,7 @@ def test_list_product_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_product_sets(**mock_args) @@ -8963,6 +8967,7 @@ def test_get_product_set_rest_required_fields( response_value._content = json_return_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_set(request) @@ -9010,6 +9015,7 @@ def test_get_product_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_set(**mock_args) @@ -9143,6 +9149,7 @@ def test_update_product_set_rest_required_fields( response_value._content = json_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_product_set(request) @@ -9193,6 +9200,7 @@ def test_update_product_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_product_set(**mock_args) @@ -9326,6 +9334,7 @@ def test_delete_product_set_rest_required_fields( response_value._content = json_return_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_set(request) @@ -9371,6 +9380,7 @@ def test_delete_product_set_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_set(**mock_args) @@ -9505,6 +9515,7 @@ def test_create_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.create_product(request) @@ -9560,6 +9571,7 @@ def test_create_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.create_product(**mock_args) @@ -9699,6 +9711,7 @@ def test_list_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_products(request) @@ -9752,6 +9765,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) @@ -9945,6 +9959,7 @@ def test_get_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_product(request) @@ -9990,6 +10005,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) @@ -10118,6 +10134,7 @@ def test_update_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.update_product(request) @@ -10166,6 +10183,7 @@ def test_update_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.update_product(**mock_args) @@ -10295,6 +10313,7 @@ def test_delete_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.delete_product(request) @@ -10338,6 +10357,7 @@ def test_delete_product_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(**mock_args) @@ -10476,6 +10496,7 @@ def test_create_reference_image_rest_required_fields( response_value._content = json_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_reference_image(request) @@ -10533,6 +10554,7 @@ def test_create_reference_image_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_reference_image(**mock_args) @@ -10668,6 +10690,7 @@ def test_delete_reference_image_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_reference_image(request) @@ -10713,6 +10736,7 @@ def test_delete_reference_image_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_reference_image(**mock_args) @@ -10858,6 +10882,7 @@ def test_list_reference_images_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_reference_images(request) @@ -10915,6 +10940,7 @@ def test_list_reference_images_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_reference_images(**mock_args) @@ -11118,6 +11144,7 @@ def test_get_reference_image_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_reference_image(request) @@ -11165,6 +11192,7 @@ def test_get_reference_image_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_reference_image(**mock_args) @@ -11303,6 +11331,7 @@ def test_add_product_to_product_set_rest_required_fields( response_value._content = json_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_product_to_product_set(request) @@ -11357,6 +11386,7 @@ def test_add_product_to_product_set_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.add_product_to_product_set(**mock_args) @@ -11496,6 +11526,7 @@ def test_remove_product_from_product_set_rest_required_fields( response_value._content = json_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_product_from_product_set(request) @@ -11552,6 +11583,7 @@ def test_remove_product_from_product_set_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.remove_product_from_product_set(**mock_args) @@ -11698,6 +11730,7 @@ def test_list_products_in_product_set_rest_required_fields( response_value._content = json_return_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_in_product_set(request) @@ -11755,6 +11788,7 @@ def test_list_products_in_product_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_in_product_set(**mock_args) @@ -11958,6 +11992,7 @@ def test_import_product_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.import_product_sets(request) @@ -12014,6 +12049,7 @@ def test_import_product_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.import_product_sets(**mock_args) @@ -12152,6 +12188,7 @@ def test_purge_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.purge_products(request) @@ -12195,6 +12232,7 @@ def test_purge_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.purge_products(**mock_args) @@ -13323,6 +13361,7 @@ def test_create_product_set_rest_bad_request( response_value.status_code = 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_product_set(request) @@ -13443,6 +13482,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_product_set(request) # Establish that the response is the type that we expect. @@ -13484,6 +13524,7 @@ def test_create_product_set_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = product_search_service.ProductSet.to_json( product_search_service.ProductSet() ) @@ -13530,6 +13571,7 @@ def test_list_product_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_product_sets(request) @@ -13565,6 +13607,7 @@ def test_list_product_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_product_sets(request) # Establish that the response is the type that we expect. @@ -13605,6 +13648,7 @@ def test_list_product_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 = product_search_service.ListProductSetsResponse.to_json( product_search_service.ListProductSetsResponse() ) @@ -13651,6 +13695,7 @@ def test_get_product_set_rest_bad_request( response_value.status_code = 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_set(request) @@ -13687,6 +13732,7 @@ def test_get_product_set_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_set(request) # Establish that the response is the type that we expect. @@ -13728,6 +13774,7 @@ def test_get_product_set_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = product_search_service.ProductSet.to_json( product_search_service.ProductSet() ) @@ -13778,6 +13825,7 @@ def test_update_product_set_rest_bad_request( response_value.status_code = 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_product_set(request) @@ -13902,6 +13950,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_product_set(request) # Establish that the response is the type that we expect. @@ -13943,6 +13992,7 @@ def test_update_product_set_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = product_search_service.ProductSet.to_json( product_search_service.ProductSet() ) @@ -13989,6 +14039,7 @@ def test_delete_product_set_rest_bad_request( response_value.status_code = 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_set(request) @@ -14019,6 +14070,7 @@ def test_delete_product_set_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_set(request) # Establish that the response is the type that we expect. @@ -14055,6 +14107,7 @@ def test_delete_product_set_rest_interceptors(null_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 = product_search_service.DeleteProductSetRequest() metadata = [ @@ -14095,6 +14148,7 @@ def test_create_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.create_product(request) @@ -14207,6 +14261,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_product(request) # Establish that the response is the type that we expect. @@ -14250,6 +14305,7 @@ def test_create_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 = product_search_service.Product.to_json( product_search_service.Product() ) @@ -14296,6 +14352,7 @@ def test_list_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_products(request) @@ -14331,6 +14388,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. @@ -14371,6 +14429,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 = product_search_service.ListProductsResponse.to_json( product_search_service.ListProductsResponse() ) @@ -14417,6 +14476,7 @@ def test_get_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_product(request) @@ -14455,6 +14515,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. @@ -14498,6 +14559,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 = product_search_service.Product.to_json( product_search_service.Product() ) @@ -14546,6 +14608,7 @@ def test_update_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.update_product(request) @@ -14660,6 +14723,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_product(request) # Establish that the response is the type that we expect. @@ -14703,6 +14767,7 @@ def test_update_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 = product_search_service.Product.to_json( product_search_service.Product() ) @@ -14749,6 +14814,7 @@ def test_delete_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.delete_product(request) @@ -14779,6 +14845,7 @@ def test_delete_product_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(request) # Establish that the response is the type that we expect. @@ -14815,6 +14882,7 @@ def test_delete_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"} request = product_search_service.DeleteProductRequest() metadata = [ @@ -14855,6 +14923,7 @@ def test_create_reference_image_rest_bad_request( response_value.status_code = 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_reference_image(request) @@ -14970,6 +15039,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_reference_image(request) # Establish that the response is the type that we expect. @@ -15011,6 +15081,7 @@ def test_create_reference_image_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = product_search_service.ReferenceImage.to_json( product_search_service.ReferenceImage() ) @@ -15059,6 +15130,7 @@ def test_delete_reference_image_rest_bad_request( response_value.status_code = 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_reference_image(request) @@ -15091,6 +15163,7 @@ def test_delete_reference_image_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_reference_image(request) # Establish that the response is the type that we expect. @@ -15127,6 +15200,7 @@ def test_delete_reference_image_rest_interceptors(null_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 = product_search_service.DeleteReferenceImageRequest() metadata = [ @@ -15167,6 +15241,7 @@ def test_list_reference_images_rest_bad_request( response_value.status_code = 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_reference_images(request) @@ -15205,6 +15280,7 @@ def test_list_reference_images_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_reference_images(request) # Establish that the response is the type that we expect. @@ -15246,6 +15322,7 @@ def test_list_reference_images_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = product_search_service.ListReferenceImagesResponse.to_json( product_search_service.ListReferenceImagesResponse() ) @@ -15294,6 +15371,7 @@ def test_get_reference_image_rest_bad_request( response_value.status_code = 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_reference_image(request) @@ -15332,6 +15410,7 @@ def test_get_reference_image_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_reference_image(request) # Establish that the response is the type that we expect. @@ -15373,6 +15452,7 @@ def test_get_reference_image_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = product_search_service.ReferenceImage.to_json( product_search_service.ReferenceImage() ) @@ -15419,6 +15499,7 @@ def test_add_product_to_product_set_rest_bad_request( response_value.status_code = 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_product_to_product_set(request) @@ -15449,6 +15530,7 @@ def test_add_product_to_product_set_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.add_product_to_product_set(request) # Establish that the response is the type that we expect. @@ -15485,6 +15567,7 @@ def test_add_product_to_product_set_rest_interceptors(null_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 = product_search_service.AddProductToProductSetRequest() metadata = [ @@ -15525,6 +15608,7 @@ def test_remove_product_from_product_set_rest_bad_request( response_value.status_code = 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_product_from_product_set(request) @@ -15555,6 +15639,7 @@ def test_remove_product_from_product_set_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.remove_product_from_product_set(request) # Establish that the response is the type that we expect. @@ -15591,6 +15676,7 @@ def test_remove_product_from_product_set_rest_interceptors(null_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 = product_search_service.RemoveProductFromProductSetRequest() metadata = [ @@ -15631,6 +15717,7 @@ def test_list_products_in_product_set_rest_bad_request( response_value.status_code = 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_in_product_set(request) @@ -15668,6 +15755,7 @@ def test_list_products_in_product_set_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_in_product_set(request) # Establish that the response is the type that we expect. @@ -15708,6 +15796,7 @@ def test_list_products_in_product_set_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = product_search_service.ListProductsInProductSetResponse.to_json( product_search_service.ListProductsInProductSetResponse() ) @@ -15754,6 +15843,7 @@ def test_import_product_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.import_product_sets(request) @@ -15784,6 +15874,7 @@ def test_import_product_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.import_product_sets(request) # Establish that the response is the type that we expect. @@ -15825,6 +15916,7 @@ def test_import_product_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -15869,6 +15961,7 @@ def test_purge_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.purge_products(request) @@ -15899,6 +15992,7 @@ def test_purge_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.purge_products(request) # Establish that the response is the type that we expect. @@ -15940,6 +16034,7 @@ def test_purge_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -15986,6 +16081,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) @@ -16016,6 +16112,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) diff --git a/packages/google-cloud-vision/tests/unit/gapic/vision_v1p1beta1/test_image_annotator.py b/packages/google-cloud-vision/tests/unit/gapic/vision_v1p1beta1/test_image_annotator.py index 4fca11157aea..bc7d67520e21 100644 --- a/packages/google-cloud-vision/tests/unit/gapic/vision_v1p1beta1/test_image_annotator.py +++ b/packages/google-cloud-vision/tests/unit/gapic/vision_v1p1beta1/test_image_annotator.py @@ -1458,6 +1458,7 @@ def test_batch_annotate_images_rest_required_fields( response_value._content = json_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_annotate_images(request) @@ -1507,6 +1508,7 @@ def test_batch_annotate_images_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_annotate_images(**mock_args) @@ -1736,6 +1738,7 @@ def test_batch_annotate_images_rest_bad_request( response_value.status_code = 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_annotate_images(request) @@ -1769,6 +1772,7 @@ def test_batch_annotate_images_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_annotate_images(request) # Establish that the response is the type that we expect. @@ -1808,6 +1812,7 @@ def test_batch_annotate_images_rest_interceptors(null_interceptor): req.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_annotator.BatchAnnotateImagesResponse.to_json( image_annotator.BatchAnnotateImagesResponse() ) diff --git a/packages/google-cloud-vision/tests/unit/gapic/vision_v1p2beta1/test_image_annotator.py b/packages/google-cloud-vision/tests/unit/gapic/vision_v1p2beta1/test_image_annotator.py index e315a83efcdc..95b558563eb8 100644 --- a/packages/google-cloud-vision/tests/unit/gapic/vision_v1p2beta1/test_image_annotator.py +++ b/packages/google-cloud-vision/tests/unit/gapic/vision_v1p2beta1/test_image_annotator.py @@ -1782,6 +1782,7 @@ def test_batch_annotate_images_rest_required_fields( response_value._content = json_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_annotate_images(request) @@ -1831,6 +1832,7 @@ def test_batch_annotate_images_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_annotate_images(**mock_args) @@ -1966,6 +1968,7 @@ def test_async_batch_annotate_files_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.async_batch_annotate_files(request) @@ -2015,6 +2018,7 @@ def test_async_batch_annotate_files_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.async_batch_annotate_files(**mock_args) @@ -2296,6 +2300,7 @@ def test_batch_annotate_images_rest_bad_request( response_value.status_code = 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_annotate_images(request) @@ -2329,6 +2334,7 @@ def test_batch_annotate_images_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_annotate_images(request) # Establish that the response is the type that we expect. @@ -2368,6 +2374,7 @@ def test_batch_annotate_images_rest_interceptors(null_interceptor): req.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_annotator.BatchAnnotateImagesResponse.to_json( image_annotator.BatchAnnotateImagesResponse() ) @@ -2414,6 +2421,7 @@ def test_async_batch_annotate_files_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.async_batch_annotate_files(request) @@ -2444,6 +2452,7 @@ def test_async_batch_annotate_files_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.async_batch_annotate_files(request) # Establish that the response is the type that we expect. @@ -2485,6 +2494,7 @@ def test_async_batch_annotate_files_rest_interceptors(null_interceptor): req.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-vision/tests/unit/gapic/vision_v1p3beta1/test_image_annotator.py b/packages/google-cloud-vision/tests/unit/gapic/vision_v1p3beta1/test_image_annotator.py index 7f289ba5bfd6..d38612cd962f 100644 --- a/packages/google-cloud-vision/tests/unit/gapic/vision_v1p3beta1/test_image_annotator.py +++ b/packages/google-cloud-vision/tests/unit/gapic/vision_v1p3beta1/test_image_annotator.py @@ -1786,6 +1786,7 @@ def test_batch_annotate_images_rest_required_fields( response_value._content = json_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_annotate_images(request) @@ -1835,6 +1836,7 @@ def test_batch_annotate_images_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_annotate_images(**mock_args) @@ -1970,6 +1972,7 @@ def test_async_batch_annotate_files_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.async_batch_annotate_files(request) @@ -2019,6 +2022,7 @@ def test_async_batch_annotate_files_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.async_batch_annotate_files(**mock_args) @@ -2300,6 +2304,7 @@ def test_batch_annotate_images_rest_bad_request( response_value.status_code = 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_annotate_images(request) @@ -2333,6 +2338,7 @@ def test_batch_annotate_images_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_annotate_images(request) # Establish that the response is the type that we expect. @@ -2372,6 +2378,7 @@ def test_batch_annotate_images_rest_interceptors(null_interceptor): req.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_annotator.BatchAnnotateImagesResponse.to_json( image_annotator.BatchAnnotateImagesResponse() ) @@ -2418,6 +2425,7 @@ def test_async_batch_annotate_files_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.async_batch_annotate_files(request) @@ -2448,6 +2456,7 @@ def test_async_batch_annotate_files_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.async_batch_annotate_files(request) # Establish that the response is the type that we expect. @@ -2489,6 +2498,7 @@ def test_async_batch_annotate_files_rest_interceptors(null_interceptor): req.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-vision/tests/unit/gapic/vision_v1p3beta1/test_product_search.py b/packages/google-cloud-vision/tests/unit/gapic/vision_v1p3beta1/test_product_search.py index 2e0bcfa82b38..b71651854ec6 100644 --- a/packages/google-cloud-vision/tests/unit/gapic/vision_v1p3beta1/test_product_search.py +++ b/packages/google-cloud-vision/tests/unit/gapic/vision_v1p3beta1/test_product_search.py @@ -8188,6 +8188,7 @@ def test_create_product_set_rest_required_fields( response_value._content = json_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_product_set(request) @@ -8243,6 +8244,7 @@ def test_create_product_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_product_set(**mock_args) @@ -8387,6 +8389,7 @@ def test_list_product_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_product_sets(request) @@ -8440,6 +8443,7 @@ def test_list_product_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_product_sets(**mock_args) @@ -8634,6 +8638,7 @@ def test_get_product_set_rest_required_fields( response_value._content = json_return_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_set(request) @@ -8681,6 +8686,7 @@ def test_get_product_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_set(**mock_args) @@ -8814,6 +8820,7 @@ def test_update_product_set_rest_required_fields( response_value._content = json_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_product_set(request) @@ -8864,6 +8871,7 @@ def test_update_product_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_product_set(**mock_args) @@ -8997,6 +9005,7 @@ def test_delete_product_set_rest_required_fields( response_value._content = json_return_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_set(request) @@ -9042,6 +9051,7 @@ def test_delete_product_set_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_set(**mock_args) @@ -9176,6 +9186,7 @@ def test_create_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.create_product(request) @@ -9231,6 +9242,7 @@ def test_create_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.create_product(**mock_args) @@ -9371,6 +9383,7 @@ def test_list_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_products(request) @@ -9424,6 +9437,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) @@ -9618,6 +9632,7 @@ def test_get_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_product(request) @@ -9663,6 +9678,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) @@ -9792,6 +9808,7 @@ def test_update_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.update_product(request) @@ -9840,6 +9857,7 @@ def test_update_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.update_product(**mock_args) @@ -9969,6 +9987,7 @@ def test_delete_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.delete_product(request) @@ -10012,6 +10031,7 @@ def test_delete_product_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(**mock_args) @@ -10151,6 +10171,7 @@ def test_create_reference_image_rest_required_fields( response_value._content = json_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_reference_image(request) @@ -10208,6 +10229,7 @@ def test_create_reference_image_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_reference_image(**mock_args) @@ -10343,6 +10365,7 @@ def test_delete_reference_image_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_reference_image(request) @@ -10388,6 +10411,7 @@ def test_delete_reference_image_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_reference_image(**mock_args) @@ -10533,6 +10557,7 @@ def test_list_reference_images_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_reference_images(request) @@ -10590,6 +10615,7 @@ def test_list_reference_images_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_reference_images(**mock_args) @@ -10793,6 +10819,7 @@ def test_get_reference_image_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_reference_image(request) @@ -10840,6 +10867,7 @@ def test_get_reference_image_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_reference_image(**mock_args) @@ -10978,6 +11006,7 @@ def test_add_product_to_product_set_rest_required_fields( response_value._content = json_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_product_to_product_set(request) @@ -11032,6 +11061,7 @@ def test_add_product_to_product_set_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.add_product_to_product_set(**mock_args) @@ -11171,6 +11201,7 @@ def test_remove_product_from_product_set_rest_required_fields( response_value._content = json_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_product_from_product_set(request) @@ -11227,6 +11258,7 @@ def test_remove_product_from_product_set_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.remove_product_from_product_set(**mock_args) @@ -11373,6 +11405,7 @@ def test_list_products_in_product_set_rest_required_fields( response_value._content = json_return_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_in_product_set(request) @@ -11430,6 +11463,7 @@ def test_list_products_in_product_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_in_product_set(**mock_args) @@ -11633,6 +11667,7 @@ def test_import_product_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.import_product_sets(request) @@ -11689,6 +11724,7 @@ def test_import_product_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.import_product_sets(**mock_args) @@ -12776,6 +12812,7 @@ def test_create_product_set_rest_bad_request( response_value.status_code = 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_product_set(request) @@ -12896,6 +12933,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_product_set(request) # Establish that the response is the type that we expect. @@ -12937,6 +12975,7 @@ def test_create_product_set_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = product_search_service.ProductSet.to_json( product_search_service.ProductSet() ) @@ -12983,6 +13022,7 @@ def test_list_product_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_product_sets(request) @@ -13018,6 +13058,7 @@ def test_list_product_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_product_sets(request) # Establish that the response is the type that we expect. @@ -13058,6 +13099,7 @@ def test_list_product_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 = product_search_service.ListProductSetsResponse.to_json( product_search_service.ListProductSetsResponse() ) @@ -13104,6 +13146,7 @@ def test_get_product_set_rest_bad_request( response_value.status_code = 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_set(request) @@ -13140,6 +13183,7 @@ def test_get_product_set_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_set(request) # Establish that the response is the type that we expect. @@ -13181,6 +13225,7 @@ def test_get_product_set_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = product_search_service.ProductSet.to_json( product_search_service.ProductSet() ) @@ -13231,6 +13276,7 @@ def test_update_product_set_rest_bad_request( response_value.status_code = 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_product_set(request) @@ -13355,6 +13401,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_product_set(request) # Establish that the response is the type that we expect. @@ -13396,6 +13443,7 @@ def test_update_product_set_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = product_search_service.ProductSet.to_json( product_search_service.ProductSet() ) @@ -13442,6 +13490,7 @@ def test_delete_product_set_rest_bad_request( response_value.status_code = 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_set(request) @@ -13472,6 +13521,7 @@ def test_delete_product_set_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_set(request) # Establish that the response is the type that we expect. @@ -13508,6 +13558,7 @@ def test_delete_product_set_rest_interceptors(null_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 = product_search_service.DeleteProductSetRequest() metadata = [ @@ -13548,6 +13599,7 @@ def test_create_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.create_product(request) @@ -13660,6 +13712,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_product(request) # Establish that the response is the type that we expect. @@ -13703,6 +13756,7 @@ def test_create_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 = product_search_service.Product.to_json( product_search_service.Product() ) @@ -13749,6 +13803,7 @@ def test_list_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_products(request) @@ -13784,6 +13839,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. @@ -13824,6 +13880,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 = product_search_service.ListProductsResponse.to_json( product_search_service.ListProductsResponse() ) @@ -13870,6 +13927,7 @@ def test_get_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_product(request) @@ -13908,6 +13966,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. @@ -13951,6 +14010,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 = product_search_service.Product.to_json( product_search_service.Product() ) @@ -13999,6 +14059,7 @@ def test_update_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.update_product(request) @@ -14113,6 +14174,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_product(request) # Establish that the response is the type that we expect. @@ -14156,6 +14218,7 @@ def test_update_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 = product_search_service.Product.to_json( product_search_service.Product() ) @@ -14202,6 +14265,7 @@ def test_delete_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.delete_product(request) @@ -14232,6 +14296,7 @@ def test_delete_product_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(request) # Establish that the response is the type that we expect. @@ -14268,6 +14333,7 @@ def test_delete_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"} request = product_search_service.DeleteProductRequest() metadata = [ @@ -14308,6 +14374,7 @@ def test_create_reference_image_rest_bad_request( response_value.status_code = 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_reference_image(request) @@ -14423,6 +14490,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_reference_image(request) # Establish that the response is the type that we expect. @@ -14464,6 +14532,7 @@ def test_create_reference_image_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = product_search_service.ReferenceImage.to_json( product_search_service.ReferenceImage() ) @@ -14512,6 +14581,7 @@ def test_delete_reference_image_rest_bad_request( response_value.status_code = 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_reference_image(request) @@ -14544,6 +14614,7 @@ def test_delete_reference_image_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_reference_image(request) # Establish that the response is the type that we expect. @@ -14580,6 +14651,7 @@ def test_delete_reference_image_rest_interceptors(null_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 = product_search_service.DeleteReferenceImageRequest() metadata = [ @@ -14620,6 +14692,7 @@ def test_list_reference_images_rest_bad_request( response_value.status_code = 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_reference_images(request) @@ -14658,6 +14731,7 @@ def test_list_reference_images_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_reference_images(request) # Establish that the response is the type that we expect. @@ -14699,6 +14773,7 @@ def test_list_reference_images_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = product_search_service.ListReferenceImagesResponse.to_json( product_search_service.ListReferenceImagesResponse() ) @@ -14747,6 +14822,7 @@ def test_get_reference_image_rest_bad_request( response_value.status_code = 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_reference_image(request) @@ -14785,6 +14861,7 @@ def test_get_reference_image_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_reference_image(request) # Establish that the response is the type that we expect. @@ -14826,6 +14903,7 @@ def test_get_reference_image_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = product_search_service.ReferenceImage.to_json( product_search_service.ReferenceImage() ) @@ -14872,6 +14950,7 @@ def test_add_product_to_product_set_rest_bad_request( response_value.status_code = 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_product_to_product_set(request) @@ -14902,6 +14981,7 @@ def test_add_product_to_product_set_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.add_product_to_product_set(request) # Establish that the response is the type that we expect. @@ -14938,6 +15018,7 @@ def test_add_product_to_product_set_rest_interceptors(null_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 = product_search_service.AddProductToProductSetRequest() metadata = [ @@ -14978,6 +15059,7 @@ def test_remove_product_from_product_set_rest_bad_request( response_value.status_code = 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_product_from_product_set(request) @@ -15008,6 +15090,7 @@ def test_remove_product_from_product_set_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.remove_product_from_product_set(request) # Establish that the response is the type that we expect. @@ -15044,6 +15127,7 @@ def test_remove_product_from_product_set_rest_interceptors(null_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 = product_search_service.RemoveProductFromProductSetRequest() metadata = [ @@ -15084,6 +15168,7 @@ def test_list_products_in_product_set_rest_bad_request( response_value.status_code = 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_in_product_set(request) @@ -15121,6 +15206,7 @@ def test_list_products_in_product_set_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_in_product_set(request) # Establish that the response is the type that we expect. @@ -15161,6 +15247,7 @@ def test_list_products_in_product_set_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = product_search_service.ListProductsInProductSetResponse.to_json( product_search_service.ListProductsInProductSetResponse() ) @@ -15207,6 +15294,7 @@ def test_import_product_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.import_product_sets(request) @@ -15237,6 +15325,7 @@ def test_import_product_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.import_product_sets(request) # Establish that the response is the type that we expect. @@ -15278,6 +15367,7 @@ def test_import_product_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-vision/tests/unit/gapic/vision_v1p4beta1/test_image_annotator.py b/packages/google-cloud-vision/tests/unit/gapic/vision_v1p4beta1/test_image_annotator.py index 8f6a1d9c4c0a..9718f97a0637 100644 --- a/packages/google-cloud-vision/tests/unit/gapic/vision_v1p4beta1/test_image_annotator.py +++ b/packages/google-cloud-vision/tests/unit/gapic/vision_v1p4beta1/test_image_annotator.py @@ -2414,6 +2414,7 @@ def test_batch_annotate_images_rest_required_fields( response_value._content = json_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_annotate_images(request) @@ -2463,6 +2464,7 @@ def test_batch_annotate_images_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_annotate_images(**mock_args) @@ -2596,6 +2598,7 @@ def test_batch_annotate_files_rest_required_fields( response_value._content = json_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_annotate_files(request) @@ -2647,6 +2650,7 @@ def test_batch_annotate_files_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_annotate_files(**mock_args) @@ -2784,6 +2788,7 @@ def test_async_batch_annotate_images_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.async_batch_annotate_images(request) @@ -2842,6 +2847,7 @@ def test_async_batch_annotate_images_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.async_batch_annotate_images(**mock_args) @@ -2980,6 +2986,7 @@ def test_async_batch_annotate_files_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.async_batch_annotate_files(request) @@ -3029,6 +3036,7 @@ def test_async_batch_annotate_files_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.async_batch_annotate_files(**mock_args) @@ -3410,6 +3418,7 @@ def test_batch_annotate_images_rest_bad_request( response_value.status_code = 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_annotate_images(request) @@ -3443,6 +3452,7 @@ def test_batch_annotate_images_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_annotate_images(request) # Establish that the response is the type that we expect. @@ -3482,6 +3492,7 @@ def test_batch_annotate_images_rest_interceptors(null_interceptor): req.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_annotator.BatchAnnotateImagesResponse.to_json( image_annotator.BatchAnnotateImagesResponse() ) @@ -3528,6 +3539,7 @@ def test_batch_annotate_files_rest_bad_request( response_value.status_code = 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_annotate_files(request) @@ -3561,6 +3573,7 @@ def test_batch_annotate_files_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_annotate_files(request) # Establish that the response is the type that we expect. @@ -3600,6 +3613,7 @@ def test_batch_annotate_files_rest_interceptors(null_interceptor): req.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_annotator.BatchAnnotateFilesResponse.to_json( image_annotator.BatchAnnotateFilesResponse() ) @@ -3646,6 +3660,7 @@ def test_async_batch_annotate_images_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.async_batch_annotate_images(request) @@ -3676,6 +3691,7 @@ def test_async_batch_annotate_images_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.async_batch_annotate_images(request) # Establish that the response is the type that we expect. @@ -3717,6 +3733,7 @@ def test_async_batch_annotate_images_rest_interceptors(null_interceptor): req.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 @@ -3761,6 +3778,7 @@ def test_async_batch_annotate_files_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.async_batch_annotate_files(request) @@ -3791,6 +3809,7 @@ def test_async_batch_annotate_files_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.async_batch_annotate_files(request) # Establish that the response is the type that we expect. @@ -3832,6 +3851,7 @@ def test_async_batch_annotate_files_rest_interceptors(null_interceptor): req.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-vision/tests/unit/gapic/vision_v1p4beta1/test_product_search.py b/packages/google-cloud-vision/tests/unit/gapic/vision_v1p4beta1/test_product_search.py index 68698377853a..e9d31f2a351f 100644 --- a/packages/google-cloud-vision/tests/unit/gapic/vision_v1p4beta1/test_product_search.py +++ b/packages/google-cloud-vision/tests/unit/gapic/vision_v1p4beta1/test_product_search.py @@ -8517,6 +8517,7 @@ def test_create_product_set_rest_required_fields( response_value._content = json_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_product_set(request) @@ -8572,6 +8573,7 @@ def test_create_product_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_product_set(**mock_args) @@ -8716,6 +8718,7 @@ def test_list_product_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_product_sets(request) @@ -8769,6 +8772,7 @@ def test_list_product_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_product_sets(**mock_args) @@ -8963,6 +8967,7 @@ def test_get_product_set_rest_required_fields( response_value._content = json_return_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_set(request) @@ -9010,6 +9015,7 @@ def test_get_product_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_set(**mock_args) @@ -9143,6 +9149,7 @@ def test_update_product_set_rest_required_fields( response_value._content = json_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_product_set(request) @@ -9193,6 +9200,7 @@ def test_update_product_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_product_set(**mock_args) @@ -9326,6 +9334,7 @@ def test_delete_product_set_rest_required_fields( response_value._content = json_return_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_set(request) @@ -9371,6 +9380,7 @@ def test_delete_product_set_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_set(**mock_args) @@ -9505,6 +9515,7 @@ def test_create_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.create_product(request) @@ -9560,6 +9571,7 @@ def test_create_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.create_product(**mock_args) @@ -9700,6 +9712,7 @@ def test_list_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_products(request) @@ -9753,6 +9766,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) @@ -9947,6 +9961,7 @@ def test_get_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_product(request) @@ -9992,6 +10007,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) @@ -10121,6 +10137,7 @@ def test_update_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.update_product(request) @@ -10169,6 +10186,7 @@ def test_update_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.update_product(**mock_args) @@ -10298,6 +10316,7 @@ def test_delete_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.delete_product(request) @@ -10341,6 +10360,7 @@ def test_delete_product_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(**mock_args) @@ -10480,6 +10500,7 @@ def test_create_reference_image_rest_required_fields( response_value._content = json_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_reference_image(request) @@ -10537,6 +10558,7 @@ def test_create_reference_image_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_reference_image(**mock_args) @@ -10672,6 +10694,7 @@ def test_delete_reference_image_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_reference_image(request) @@ -10717,6 +10740,7 @@ def test_delete_reference_image_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_reference_image(**mock_args) @@ -10862,6 +10886,7 @@ def test_list_reference_images_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_reference_images(request) @@ -10919,6 +10944,7 @@ def test_list_reference_images_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_reference_images(**mock_args) @@ -11122,6 +11148,7 @@ def test_get_reference_image_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_reference_image(request) @@ -11169,6 +11196,7 @@ def test_get_reference_image_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_reference_image(**mock_args) @@ -11307,6 +11335,7 @@ def test_add_product_to_product_set_rest_required_fields( response_value._content = json_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_product_to_product_set(request) @@ -11361,6 +11390,7 @@ def test_add_product_to_product_set_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.add_product_to_product_set(**mock_args) @@ -11500,6 +11530,7 @@ def test_remove_product_from_product_set_rest_required_fields( response_value._content = json_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_product_from_product_set(request) @@ -11556,6 +11587,7 @@ def test_remove_product_from_product_set_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.remove_product_from_product_set(**mock_args) @@ -11702,6 +11734,7 @@ def test_list_products_in_product_set_rest_required_fields( response_value._content = json_return_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_in_product_set(request) @@ -11759,6 +11792,7 @@ def test_list_products_in_product_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_in_product_set(**mock_args) @@ -11962,6 +11996,7 @@ def test_import_product_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.import_product_sets(request) @@ -12018,6 +12053,7 @@ def test_import_product_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.import_product_sets(**mock_args) @@ -12156,6 +12192,7 @@ def test_purge_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.purge_products(request) @@ -12199,6 +12236,7 @@ def test_purge_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.purge_products(**mock_args) @@ -13327,6 +13365,7 @@ def test_create_product_set_rest_bad_request( response_value.status_code = 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_product_set(request) @@ -13447,6 +13486,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_product_set(request) # Establish that the response is the type that we expect. @@ -13488,6 +13528,7 @@ def test_create_product_set_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = product_search_service.ProductSet.to_json( product_search_service.ProductSet() ) @@ -13534,6 +13575,7 @@ def test_list_product_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_product_sets(request) @@ -13569,6 +13611,7 @@ def test_list_product_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_product_sets(request) # Establish that the response is the type that we expect. @@ -13609,6 +13652,7 @@ def test_list_product_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 = product_search_service.ListProductSetsResponse.to_json( product_search_service.ListProductSetsResponse() ) @@ -13655,6 +13699,7 @@ def test_get_product_set_rest_bad_request( response_value.status_code = 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_set(request) @@ -13691,6 +13736,7 @@ def test_get_product_set_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_set(request) # Establish that the response is the type that we expect. @@ -13732,6 +13778,7 @@ def test_get_product_set_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = product_search_service.ProductSet.to_json( product_search_service.ProductSet() ) @@ -13782,6 +13829,7 @@ def test_update_product_set_rest_bad_request( response_value.status_code = 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_product_set(request) @@ -13906,6 +13954,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_product_set(request) # Establish that the response is the type that we expect. @@ -13947,6 +13996,7 @@ def test_update_product_set_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = product_search_service.ProductSet.to_json( product_search_service.ProductSet() ) @@ -13993,6 +14043,7 @@ def test_delete_product_set_rest_bad_request( response_value.status_code = 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_set(request) @@ -14023,6 +14074,7 @@ def test_delete_product_set_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_set(request) # Establish that the response is the type that we expect. @@ -14059,6 +14111,7 @@ def test_delete_product_set_rest_interceptors(null_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 = product_search_service.DeleteProductSetRequest() metadata = [ @@ -14099,6 +14152,7 @@ def test_create_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.create_product(request) @@ -14211,6 +14265,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_product(request) # Establish that the response is the type that we expect. @@ -14254,6 +14309,7 @@ def test_create_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 = product_search_service.Product.to_json( product_search_service.Product() ) @@ -14300,6 +14356,7 @@ def test_list_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_products(request) @@ -14335,6 +14392,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. @@ -14375,6 +14433,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 = product_search_service.ListProductsResponse.to_json( product_search_service.ListProductsResponse() ) @@ -14421,6 +14480,7 @@ def test_get_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_product(request) @@ -14459,6 +14519,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. @@ -14502,6 +14563,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 = product_search_service.Product.to_json( product_search_service.Product() ) @@ -14550,6 +14612,7 @@ def test_update_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.update_product(request) @@ -14664,6 +14727,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_product(request) # Establish that the response is the type that we expect. @@ -14707,6 +14771,7 @@ def test_update_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 = product_search_service.Product.to_json( product_search_service.Product() ) @@ -14753,6 +14818,7 @@ def test_delete_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.delete_product(request) @@ -14783,6 +14849,7 @@ def test_delete_product_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(request) # Establish that the response is the type that we expect. @@ -14819,6 +14886,7 @@ def test_delete_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"} request = product_search_service.DeleteProductRequest() metadata = [ @@ -14859,6 +14927,7 @@ def test_create_reference_image_rest_bad_request( response_value.status_code = 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_reference_image(request) @@ -14974,6 +15043,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_reference_image(request) # Establish that the response is the type that we expect. @@ -15015,6 +15085,7 @@ def test_create_reference_image_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = product_search_service.ReferenceImage.to_json( product_search_service.ReferenceImage() ) @@ -15063,6 +15134,7 @@ def test_delete_reference_image_rest_bad_request( response_value.status_code = 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_reference_image(request) @@ -15095,6 +15167,7 @@ def test_delete_reference_image_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_reference_image(request) # Establish that the response is the type that we expect. @@ -15131,6 +15204,7 @@ def test_delete_reference_image_rest_interceptors(null_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 = product_search_service.DeleteReferenceImageRequest() metadata = [ @@ -15171,6 +15245,7 @@ def test_list_reference_images_rest_bad_request( response_value.status_code = 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_reference_images(request) @@ -15209,6 +15284,7 @@ def test_list_reference_images_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_reference_images(request) # Establish that the response is the type that we expect. @@ -15250,6 +15326,7 @@ def test_list_reference_images_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = product_search_service.ListReferenceImagesResponse.to_json( product_search_service.ListReferenceImagesResponse() ) @@ -15298,6 +15375,7 @@ def test_get_reference_image_rest_bad_request( response_value.status_code = 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_reference_image(request) @@ -15336,6 +15414,7 @@ def test_get_reference_image_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_reference_image(request) # Establish that the response is the type that we expect. @@ -15377,6 +15456,7 @@ def test_get_reference_image_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = product_search_service.ReferenceImage.to_json( product_search_service.ReferenceImage() ) @@ -15423,6 +15503,7 @@ def test_add_product_to_product_set_rest_bad_request( response_value.status_code = 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_product_to_product_set(request) @@ -15453,6 +15534,7 @@ def test_add_product_to_product_set_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.add_product_to_product_set(request) # Establish that the response is the type that we expect. @@ -15489,6 +15571,7 @@ def test_add_product_to_product_set_rest_interceptors(null_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 = product_search_service.AddProductToProductSetRequest() metadata = [ @@ -15529,6 +15612,7 @@ def test_remove_product_from_product_set_rest_bad_request( response_value.status_code = 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_product_from_product_set(request) @@ -15559,6 +15643,7 @@ def test_remove_product_from_product_set_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.remove_product_from_product_set(request) # Establish that the response is the type that we expect. @@ -15595,6 +15680,7 @@ def test_remove_product_from_product_set_rest_interceptors(null_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 = product_search_service.RemoveProductFromProductSetRequest() metadata = [ @@ -15635,6 +15721,7 @@ def test_list_products_in_product_set_rest_bad_request( response_value.status_code = 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_in_product_set(request) @@ -15672,6 +15759,7 @@ def test_list_products_in_product_set_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_in_product_set(request) # Establish that the response is the type that we expect. @@ -15712,6 +15800,7 @@ def test_list_products_in_product_set_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = product_search_service.ListProductsInProductSetResponse.to_json( product_search_service.ListProductsInProductSetResponse() ) @@ -15758,6 +15847,7 @@ def test_import_product_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.import_product_sets(request) @@ -15788,6 +15878,7 @@ def test_import_product_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.import_product_sets(request) # Establish that the response is the type that we expect. @@ -15829,6 +15920,7 @@ def test_import_product_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -15873,6 +15965,7 @@ def test_purge_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.purge_products(request) @@ -15903,6 +15996,7 @@ def test_purge_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.purge_products(request) # Establish that the response is the type that we expect. @@ -15944,6 +16038,7 @@ def test_purge_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-visionai/google/cloud/visionai/gapic_version.py b/packages/google-cloud-visionai/google/cloud/visionai/gapic_version.py index e9c4bb5650f3..558c8aab67c5 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai/gapic_version.py +++ b/packages/google-cloud-visionai/google/cloud/visionai/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-visionai/google/cloud/visionai_v1/gapic_version.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/gapic_version.py index e9c4bb5650f3..558c8aab67c5 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/gapic_version.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_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-visionai/google/cloud/visionai_v1/services/app_platform/async_client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/async_client.py index e76cda9c069f..9ea8990b70f9 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/async_client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/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, AppPlatformTransport from .transports.grpc_asyncio import AppPlatformGrpcAsyncIOTransport +try: + from google.api_core import client_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 AppPlatformAsyncClient: """Service describing handlers for resources""" @@ -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.visionai_v1.AppPlatformAsyncClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "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.visionai.v1.AppPlatform", + "credentialsType": None, + }, + ) + async def list_applications( self, request: Optional[Union[platform.ListApplicationsRequest, dict]] = None, @@ -275,7 +307,7 @@ async def list_applications( 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.ListApplicationsAsyncPager: r"""Lists Applications in a given project and location. @@ -320,8 +352,10 @@ async def sample_list_applications(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.app_platform.pagers.ListApplicationsAsyncPager: @@ -396,7 +430,7 @@ async def get_application( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Application: r"""Gets details of a single Application. @@ -437,8 +471,10 @@ async def sample_get_application(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Application: @@ -498,7 +534,7 @@ async def create_application( application: Optional[platform.Application] = None, retry: OptionalRetry = gapic_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 Application in a given project and location. @@ -554,8 +590,10 @@ async def sample_create_application(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -630,7 +668,7 @@ async def update_application( 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 Application. @@ -689,8 +727,10 @@ async def sample_update_application(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -766,7 +806,7 @@ async def delete_application( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Application. @@ -811,8 +851,10 @@ async def sample_delete_application(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -891,7 +933,7 @@ async def deploy_application( name: Optional[str] = None, retry: OptionalRetry = gapic_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 single Application. @@ -940,8 +982,10 @@ async def sample_deploy_application(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1012,7 +1056,7 @@ async def undeploy_application( name: Optional[str] = None, retry: OptionalRetry = gapic_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 single Application. @@ -1062,8 +1106,10 @@ async def sample_undeploy_application(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1137,7 +1183,7 @@ async def add_application_stream_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]]] = (), ) -> operation_async.AsyncOperation: r"""Adds target stream input to the Application. If the Application is deployed, the corresponding new @@ -1190,8 +1236,10 @@ async def sample_add_application_stream_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.api_core.operation_async.AsyncOperation: @@ -1265,7 +1313,7 @@ async def remove_application_stream_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]]] = (), ) -> operation_async.AsyncOperation: r"""Remove target stream input to the Application, if the Application is deployed, the corresponding instance @@ -1318,8 +1366,10 @@ async def sample_remove_application_stream_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.api_core.operation_async.AsyncOperation: @@ -1393,7 +1443,7 @@ async def update_application_stream_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]]] = (), ) -> operation_async.AsyncOperation: r"""Update target stream input to the Application, if the Application is deployed, the corresponding instance based will @@ -1446,8 +1496,10 @@ async def sample_update_application_stream_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.api_core.operation_async.AsyncOperation: @@ -1519,7 +1571,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 Instances in a given project and location. @@ -1564,8 +1616,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.visionai_v1.services.app_platform.pagers.ListInstancesAsyncPager: @@ -1640,7 +1694,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]]] = (), ) -> platform.Instance: r"""Gets details of a single Instance. @@ -1681,8 +1735,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.visionai_v1.types.Instance: @@ -1745,7 +1801,7 @@ async def create_application_instances( name: Optional[str] = None, retry: OptionalRetry = gapic_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 target stream input to the Application. If the Application is deployed, the corresponding new @@ -1803,8 +1859,10 @@ async def sample_create_application_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.api_core.operation_async.AsyncOperation: @@ -1878,7 +1936,7 @@ async def delete_application_instances( name: Optional[str] = None, retry: OptionalRetry = gapic_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"""Remove target stream input to the Application, if the Application is deployed, the corresponding instance @@ -1932,8 +1990,10 @@ async def sample_delete_application_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.api_core.operation_async.AsyncOperation: @@ -2011,7 +2071,7 @@ async def update_application_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]]] = (), ) -> operation_async.AsyncOperation: r"""Adds target stream input to the Application. If the Application is deployed, the corresponding new @@ -2069,8 +2129,10 @@ async def sample_update_application_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.api_core.operation_async.AsyncOperation: @@ -2144,7 +2206,7 @@ async def list_drafts( 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.ListDraftsAsyncPager: r"""Lists Drafts in a given project and location. @@ -2189,8 +2251,10 @@ async def sample_list_drafts(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.app_platform.pagers.ListDraftsAsyncPager: @@ -2265,7 +2329,7 @@ async def get_draft( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Draft: r"""Gets details of a single Draft. @@ -2306,8 +2370,10 @@ async def sample_get_draft(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Draft: @@ -2368,7 +2434,7 @@ async def create_draft( draft_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 Draft in a given project and location. @@ -2430,8 +2496,10 @@ async def sample_create_draft(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2508,7 +2576,7 @@ async def update_draft( 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 Draft. @@ -2567,8 +2635,10 @@ async def sample_update_draft(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2644,7 +2714,7 @@ async def delete_draft( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Draft. @@ -2689,8 +2759,10 @@ async def sample_delete_draft(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2769,7 +2841,7 @@ async def list_processors( 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.ListProcessorsAsyncPager: r"""Lists Processors in a given project and location. @@ -2814,8 +2886,10 @@ async def sample_list_processors(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.app_platform.pagers.ListProcessorsAsyncPager: @@ -2890,7 +2964,7 @@ async def list_prebuilt_processors( 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]]] = (), ) -> platform.ListPrebuiltProcessorsResponse: r"""ListPrebuiltProcessors is a custom pass-through verb that Lists Prebuilt Processors. @@ -2933,8 +3007,10 @@ async def sample_list_prebuilt_processors(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.ListPrebuiltProcessorsResponse: @@ -2995,7 +3071,7 @@ async def get_processor( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Processor: r"""Gets details of a single Processor. @@ -3036,8 +3112,10 @@ async def sample_get_processor(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Processor: @@ -3100,7 +3178,7 @@ async def create_processor( processor_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 Processor in a given project and location. @@ -3163,8 +3241,10 @@ async def sample_create_processor(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3240,7 +3320,7 @@ async def update_processor( 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 Processor. @@ -3299,8 +3379,10 @@ async def sample_update_processor(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3375,7 +3457,7 @@ async def delete_processor( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Processor. @@ -3420,8 +3502,10 @@ async def sample_delete_processor(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3499,7 +3583,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. @@ -3510,8 +3594,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. @@ -3552,7 +3638,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. @@ -3563,8 +3649,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. @@ -3605,7 +3693,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. @@ -3621,8 +3709,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 """ @@ -3659,7 +3749,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. @@ -3674,8 +3764,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 """ diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/client.py index 5f54a1eeff92..b69e79da45d5 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/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 @@ -682,6 +692,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( @@ -744,6 +758,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.visionai_v1.AppPlatformClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "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.visionai.v1.AppPlatform", + "credentialsType": None, + }, + ) + def list_applications( self, request: Optional[Union[platform.ListApplicationsRequest, dict]] = None, @@ -751,7 +788,7 @@ def list_applications( 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.ListApplicationsPager: r"""Lists Applications in a given project and location. @@ -796,8 +833,10 @@ def sample_list_applications(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.app_platform.pagers.ListApplicationsPager: @@ -869,7 +908,7 @@ def get_application( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Application: r"""Gets details of a single Application. @@ -910,8 +949,10 @@ def sample_get_application(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Application: @@ -968,7 +1009,7 @@ def create_application( application: Optional[platform.Application] = None, retry: OptionalRetry = gapic_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 Application in a given project and location. @@ -1024,8 +1065,10 @@ def sample_create_application(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1097,7 +1140,7 @@ def update_application( 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 Application. @@ -1156,8 +1199,10 @@ def sample_update_application(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1230,7 +1275,7 @@ def delete_application( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Application. @@ -1275,8 +1320,10 @@ def sample_delete_application(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1352,7 +1399,7 @@ def deploy_application( name: Optional[str] = None, retry: OptionalRetry = gapic_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 single Application. @@ -1401,8 +1448,10 @@ def sample_deploy_application(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1470,7 +1519,7 @@ def undeploy_application( name: Optional[str] = None, retry: OptionalRetry = gapic_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 single Application. @@ -1520,8 +1569,10 @@ def sample_undeploy_application(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1592,7 +1643,7 @@ def add_application_stream_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]]] = (), ) -> operation.Operation: r"""Adds target stream input to the Application. If the Application is deployed, the corresponding new @@ -1645,8 +1696,10 @@ def sample_add_application_stream_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.api_core.operation.Operation: @@ -1719,7 +1772,7 @@ def remove_application_stream_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]]] = (), ) -> operation.Operation: r"""Remove target stream input to the Application, if the Application is deployed, the corresponding instance @@ -1772,8 +1825,10 @@ def sample_remove_application_stream_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.api_core.operation.Operation: @@ -1846,7 +1901,7 @@ def update_application_stream_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]]] = (), ) -> operation.Operation: r"""Update target stream input to the Application, if the Application is deployed, the corresponding instance based will @@ -1899,8 +1954,10 @@ def sample_update_application_stream_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.api_core.operation.Operation: @@ -1971,7 +2028,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 Instances in a given project and location. @@ -2016,8 +2073,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.visionai_v1.services.app_platform.pagers.ListInstancesPager: @@ -2089,7 +2148,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]]] = (), ) -> platform.Instance: r"""Gets details of a single Instance. @@ -2130,8 +2189,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.visionai_v1.types.Instance: @@ -2191,7 +2252,7 @@ def create_application_instances( name: Optional[str] = None, retry: OptionalRetry = gapic_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 target stream input to the Application. If the Application is deployed, the corresponding new @@ -2249,8 +2310,10 @@ def sample_create_application_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.operation.Operation: @@ -2323,7 +2386,7 @@ def delete_application_instances( name: Optional[str] = None, retry: OptionalRetry = gapic_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"""Remove target stream input to the Application, if the Application is deployed, the corresponding instance @@ -2377,8 +2440,10 @@ def sample_delete_application_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.operation.Operation: @@ -2455,7 +2520,7 @@ def update_application_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]]] = (), ) -> operation.Operation: r"""Adds target stream input to the Application. If the Application is deployed, the corresponding new @@ -2513,8 +2578,10 @@ def sample_update_application_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.operation.Operation: @@ -2587,7 +2654,7 @@ def list_drafts( 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.ListDraftsPager: r"""Lists Drafts in a given project and location. @@ -2632,8 +2699,10 @@ def sample_list_drafts(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.app_platform.pagers.ListDraftsPager: @@ -2705,7 +2774,7 @@ def get_draft( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Draft: r"""Gets details of a single Draft. @@ -2746,8 +2815,10 @@ def sample_get_draft(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Draft: @@ -2805,7 +2876,7 @@ def create_draft( draft_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 Draft in a given project and location. @@ -2867,8 +2938,10 @@ def sample_create_draft(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2942,7 +3015,7 @@ def update_draft( 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 Draft. @@ -3001,8 +3074,10 @@ def sample_update_draft(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3075,7 +3150,7 @@ def delete_draft( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Draft. @@ -3120,8 +3195,10 @@ def sample_delete_draft(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3197,7 +3274,7 @@ def list_processors( 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.ListProcessorsPager: r"""Lists Processors in a given project and location. @@ -3242,8 +3319,10 @@ def sample_list_processors(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.app_platform.pagers.ListProcessorsPager: @@ -3315,7 +3394,7 @@ def list_prebuilt_processors( 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]]] = (), ) -> platform.ListPrebuiltProcessorsResponse: r"""ListPrebuiltProcessors is a custom pass-through verb that Lists Prebuilt Processors. @@ -3358,8 +3437,10 @@ def sample_list_prebuilt_processors(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.ListPrebuiltProcessorsResponse: @@ -3417,7 +3498,7 @@ def get_processor( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Processor: r"""Gets details of a single Processor. @@ -3458,8 +3539,10 @@ def sample_get_processor(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Processor: @@ -3519,7 +3602,7 @@ def create_processor( processor_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 Processor in a given project and location. @@ -3582,8 +3665,10 @@ def sample_create_processor(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3656,7 +3741,7 @@ def update_processor( 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 Processor. @@ -3715,8 +3800,10 @@ def sample_update_processor(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3788,7 +3875,7 @@ def delete_processor( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Processor. @@ -3833,8 +3920,10 @@ def sample_delete_processor(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3922,7 +4011,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. @@ -3933,8 +4022,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. @@ -3975,7 +4066,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. @@ -3986,8 +4077,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. @@ -4028,7 +4121,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. @@ -4044,8 +4137,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 """ @@ -4082,7 +4177,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. @@ -4097,8 +4192,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 """ diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/pagers.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/pagers.py index 3ebc5d8aabed..ca5d097251f5 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/pagers.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/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 = platform.ListApplicationsRequest(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 = platform.ListApplicationsRequest(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 = platform.ListInstancesRequest(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 = platform.ListInstancesRequest(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 = platform.ListDraftsRequest(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 = platform.ListDraftsRequest(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 = platform.ListProcessorsRequest(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 = platform.ListProcessorsRequest(request) diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/transports/grpc.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/transports/grpc.py index 1d37ac4d0390..54d6f86d4a69 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/transports/grpc.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/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.visionai_v1.types import platform from .base import DEFAULT_CLIENT_INFO, AppPlatformTransport +try: + from google.api_core import client_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.visionai.v1.AppPlatform", + "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.visionai.v1.AppPlatform", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AppPlatformGrpcTransport(AppPlatformTransport): """gRPC backend transport for AppPlatform. @@ -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_applications( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_applications" not in self._stubs: - self._stubs["list_applications"] = self.grpc_channel.unary_unary( + self._stubs["list_applications"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/ListApplications", request_serializer=platform.ListApplicationsRequest.serialize, response_deserializer=platform.ListApplicationsResponse.deserialize, @@ -300,7 +388,7 @@ def get_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_application" not in self._stubs: - self._stubs["get_application"] = self.grpc_channel.unary_unary( + self._stubs["get_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/GetApplication", request_serializer=platform.GetApplicationRequest.serialize, response_deserializer=platform.Application.deserialize, @@ -327,7 +415,7 @@ def create_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_application" not in self._stubs: - self._stubs["create_application"] = self.grpc_channel.unary_unary( + self._stubs["create_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/CreateApplication", request_serializer=platform.CreateApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -353,7 +441,7 @@ def update_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_application" not in self._stubs: - self._stubs["update_application"] = self.grpc_channel.unary_unary( + self._stubs["update_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/UpdateApplication", request_serializer=platform.UpdateApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -379,7 +467,7 @@ def delete_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_application" not in self._stubs: - self._stubs["delete_application"] = self.grpc_channel.unary_unary( + self._stubs["delete_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/DeleteApplication", request_serializer=platform.DeleteApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -405,7 +493,7 @@ def deploy_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "deploy_application" not in self._stubs: - self._stubs["deploy_application"] = self.grpc_channel.unary_unary( + self._stubs["deploy_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/DeployApplication", request_serializer=platform.DeployApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -431,7 +519,7 @@ def undeploy_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undeploy_application" not in self._stubs: - self._stubs["undeploy_application"] = self.grpc_channel.unary_unary( + self._stubs["undeploy_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/UndeployApplication", request_serializer=platform.UndeployApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -462,7 +550,9 @@ def add_application_stream_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_application_stream_input" not in self._stubs: - self._stubs["add_application_stream_input"] = self.grpc_channel.unary_unary( + self._stubs[ + "add_application_stream_input" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/AddApplicationStreamInput", request_serializer=platform.AddApplicationStreamInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -496,7 +586,7 @@ def remove_application_stream_input( if "remove_application_stream_input" not in self._stubs: self._stubs[ "remove_application_stream_input" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/RemoveApplicationStreamInput", request_serializer=platform.RemoveApplicationStreamInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -530,7 +620,7 @@ def update_application_stream_input( if "update_application_stream_input" not in self._stubs: self._stubs[ "update_application_stream_input" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/UpdateApplicationStreamInput", request_serializer=platform.UpdateApplicationStreamInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -556,7 +646,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.visionai.v1.AppPlatform/ListInstances", request_serializer=platform.ListInstancesRequest.serialize, response_deserializer=platform.ListInstancesResponse.deserialize, @@ -582,7 +672,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.visionai.v1.AppPlatform/GetInstance", request_serializer=platform.GetInstanceRequest.serialize, response_deserializer=platform.Instance.deserialize, @@ -613,7 +703,9 @@ def create_application_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_application_instances" not in self._stubs: - self._stubs["create_application_instances"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_application_instances" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/CreateApplicationInstances", request_serializer=platform.CreateApplicationInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -644,7 +736,9 @@ def delete_application_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_application_instances" not in self._stubs: - self._stubs["delete_application_instances"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_application_instances" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/DeleteApplicationInstances", request_serializer=platform.DeleteApplicationInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -675,7 +769,9 @@ def update_application_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_application_instances" not in self._stubs: - self._stubs["update_application_instances"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_application_instances" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/UpdateApplicationInstances", request_serializer=platform.UpdateApplicationInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -701,7 +797,7 @@ def list_drafts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_drafts" not in self._stubs: - self._stubs["list_drafts"] = self.grpc_channel.unary_unary( + self._stubs["list_drafts"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/ListDrafts", request_serializer=platform.ListDraftsRequest.serialize, response_deserializer=platform.ListDraftsResponse.deserialize, @@ -725,7 +821,7 @@ def get_draft(self) -> Callable[[platform.GetDraftRequest], platform.Draft]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_draft" not in self._stubs: - self._stubs["get_draft"] = self.grpc_channel.unary_unary( + self._stubs["get_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/GetDraft", request_serializer=platform.GetDraftRequest.serialize, response_deserializer=platform.Draft.deserialize, @@ -751,7 +847,7 @@ def create_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_draft" not in self._stubs: - self._stubs["create_draft"] = self.grpc_channel.unary_unary( + self._stubs["create_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/CreateDraft", request_serializer=platform.CreateDraftRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -777,7 +873,7 @@ def update_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_draft" not in self._stubs: - self._stubs["update_draft"] = self.grpc_channel.unary_unary( + self._stubs["update_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/UpdateDraft", request_serializer=platform.UpdateDraftRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -803,7 +899,7 @@ def delete_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_draft" not in self._stubs: - self._stubs["delete_draft"] = self.grpc_channel.unary_unary( + self._stubs["delete_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/DeleteDraft", request_serializer=platform.DeleteDraftRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -829,7 +925,7 @@ def list_processors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_processors" not in self._stubs: - self._stubs["list_processors"] = self.grpc_channel.unary_unary( + self._stubs["list_processors"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/ListProcessors", request_serializer=platform.ListProcessorsRequest.serialize, response_deserializer=platform.ListProcessorsResponse.deserialize, @@ -859,7 +955,7 @@ def list_prebuilt_processors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_prebuilt_processors" not in self._stubs: - self._stubs["list_prebuilt_processors"] = self.grpc_channel.unary_unary( + self._stubs["list_prebuilt_processors"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/ListPrebuiltProcessors", request_serializer=platform.ListPrebuiltProcessorsRequest.serialize, response_deserializer=platform.ListPrebuiltProcessorsResponse.deserialize, @@ -885,7 +981,7 @@ def get_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_processor" not in self._stubs: - self._stubs["get_processor"] = self.grpc_channel.unary_unary( + self._stubs["get_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/GetProcessor", request_serializer=platform.GetProcessorRequest.serialize, response_deserializer=platform.Processor.deserialize, @@ -912,7 +1008,7 @@ def create_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_processor" not in self._stubs: - self._stubs["create_processor"] = self.grpc_channel.unary_unary( + self._stubs["create_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/CreateProcessor", request_serializer=platform.CreateProcessorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -938,7 +1034,7 @@ def update_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_processor" not in self._stubs: - self._stubs["update_processor"] = self.grpc_channel.unary_unary( + self._stubs["update_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/UpdateProcessor", request_serializer=platform.UpdateProcessorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -964,7 +1060,7 @@ def delete_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_processor" not in self._stubs: - self._stubs["delete_processor"] = self.grpc_channel.unary_unary( + self._stubs["delete_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/DeleteProcessor", request_serializer=platform.DeleteProcessorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -972,7 +1068,7 @@ def delete_processor( return self._stubs["delete_processor"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -984,7 +1080,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, @@ -1001,7 +1097,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, @@ -1018,7 +1114,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, @@ -1037,7 +1133,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-visionai/google/cloud/visionai_v1/services/app_platform/transports/grpc_asyncio.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/transports/grpc_asyncio.py index 73c184c06dbc..e2e0d33fc07c 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/transports/grpc_asyncio.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/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.visionai_v1.types import platform from .base import DEFAULT_CLIENT_INFO, AppPlatformTransport from .grpc import AppPlatformGrpcTransport +try: + from google.api_core import client_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.visionai.v1.AppPlatform", + "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.visionai.v1.AppPlatform", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AppPlatformGrpcAsyncIOTransport(AppPlatformTransport): """gRPC AsyncIO backend transport for AppPlatform. @@ -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. @@ -284,7 +369,7 @@ def list_applications( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_applications" not in self._stubs: - self._stubs["list_applications"] = self.grpc_channel.unary_unary( + self._stubs["list_applications"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/ListApplications", request_serializer=platform.ListApplicationsRequest.serialize, response_deserializer=platform.ListApplicationsResponse.deserialize, @@ -310,7 +395,7 @@ def get_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_application" not in self._stubs: - self._stubs["get_application"] = self.grpc_channel.unary_unary( + self._stubs["get_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/GetApplication", request_serializer=platform.GetApplicationRequest.serialize, response_deserializer=platform.Application.deserialize, @@ -339,7 +424,7 @@ def create_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_application" not in self._stubs: - self._stubs["create_application"] = self.grpc_channel.unary_unary( + self._stubs["create_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/CreateApplication", request_serializer=platform.CreateApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -367,7 +452,7 @@ def update_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_application" not in self._stubs: - self._stubs["update_application"] = self.grpc_channel.unary_unary( + self._stubs["update_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/UpdateApplication", request_serializer=platform.UpdateApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -395,7 +480,7 @@ def delete_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_application" not in self._stubs: - self._stubs["delete_application"] = self.grpc_channel.unary_unary( + self._stubs["delete_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/DeleteApplication", request_serializer=platform.DeleteApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -423,7 +508,7 @@ def deploy_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "deploy_application" not in self._stubs: - self._stubs["deploy_application"] = self.grpc_channel.unary_unary( + self._stubs["deploy_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/DeployApplication", request_serializer=platform.DeployApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -451,7 +536,7 @@ def undeploy_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undeploy_application" not in self._stubs: - self._stubs["undeploy_application"] = self.grpc_channel.unary_unary( + self._stubs["undeploy_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/UndeployApplication", request_serializer=platform.UndeployApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -482,7 +567,9 @@ def add_application_stream_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_application_stream_input" not in self._stubs: - self._stubs["add_application_stream_input"] = self.grpc_channel.unary_unary( + self._stubs[ + "add_application_stream_input" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/AddApplicationStreamInput", request_serializer=platform.AddApplicationStreamInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -517,7 +604,7 @@ def remove_application_stream_input( if "remove_application_stream_input" not in self._stubs: self._stubs[ "remove_application_stream_input" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/RemoveApplicationStreamInput", request_serializer=platform.RemoveApplicationStreamInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -552,7 +639,7 @@ def update_application_stream_input( if "update_application_stream_input" not in self._stubs: self._stubs[ "update_application_stream_input" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/UpdateApplicationStreamInput", request_serializer=platform.UpdateApplicationStreamInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -580,7 +667,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.visionai.v1.AppPlatform/ListInstances", request_serializer=platform.ListInstancesRequest.serialize, response_deserializer=platform.ListInstancesResponse.deserialize, @@ -606,7 +693,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.visionai.v1.AppPlatform/GetInstance", request_serializer=platform.GetInstanceRequest.serialize, response_deserializer=platform.Instance.deserialize, @@ -638,7 +725,9 @@ def create_application_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_application_instances" not in self._stubs: - self._stubs["create_application_instances"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_application_instances" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/CreateApplicationInstances", request_serializer=platform.CreateApplicationInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -670,7 +759,9 @@ def delete_application_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_application_instances" not in self._stubs: - self._stubs["delete_application_instances"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_application_instances" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/DeleteApplicationInstances", request_serializer=platform.DeleteApplicationInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -702,7 +793,9 @@ def update_application_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_application_instances" not in self._stubs: - self._stubs["update_application_instances"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_application_instances" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/UpdateApplicationInstances", request_serializer=platform.UpdateApplicationInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -728,7 +821,7 @@ def list_drafts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_drafts" not in self._stubs: - self._stubs["list_drafts"] = self.grpc_channel.unary_unary( + self._stubs["list_drafts"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/ListDrafts", request_serializer=platform.ListDraftsRequest.serialize, response_deserializer=platform.ListDraftsResponse.deserialize, @@ -754,7 +847,7 @@ def get_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_draft" not in self._stubs: - self._stubs["get_draft"] = self.grpc_channel.unary_unary( + self._stubs["get_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/GetDraft", request_serializer=platform.GetDraftRequest.serialize, response_deserializer=platform.Draft.deserialize, @@ -780,7 +873,7 @@ def create_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_draft" not in self._stubs: - self._stubs["create_draft"] = self.grpc_channel.unary_unary( + self._stubs["create_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/CreateDraft", request_serializer=platform.CreateDraftRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -806,7 +899,7 @@ def update_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_draft" not in self._stubs: - self._stubs["update_draft"] = self.grpc_channel.unary_unary( + self._stubs["update_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/UpdateDraft", request_serializer=platform.UpdateDraftRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -832,7 +925,7 @@ def delete_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_draft" not in self._stubs: - self._stubs["delete_draft"] = self.grpc_channel.unary_unary( + self._stubs["delete_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/DeleteDraft", request_serializer=platform.DeleteDraftRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -860,7 +953,7 @@ def list_processors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_processors" not in self._stubs: - self._stubs["list_processors"] = self.grpc_channel.unary_unary( + self._stubs["list_processors"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/ListProcessors", request_serializer=platform.ListProcessorsRequest.serialize, response_deserializer=platform.ListProcessorsResponse.deserialize, @@ -890,7 +983,7 @@ def list_prebuilt_processors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_prebuilt_processors" not in self._stubs: - self._stubs["list_prebuilt_processors"] = self.grpc_channel.unary_unary( + self._stubs["list_prebuilt_processors"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/ListPrebuiltProcessors", request_serializer=platform.ListPrebuiltProcessorsRequest.serialize, response_deserializer=platform.ListPrebuiltProcessorsResponse.deserialize, @@ -916,7 +1009,7 @@ def get_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_processor" not in self._stubs: - self._stubs["get_processor"] = self.grpc_channel.unary_unary( + self._stubs["get_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/GetProcessor", request_serializer=platform.GetProcessorRequest.serialize, response_deserializer=platform.Processor.deserialize, @@ -945,7 +1038,7 @@ def create_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_processor" not in self._stubs: - self._stubs["create_processor"] = self.grpc_channel.unary_unary( + self._stubs["create_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/CreateProcessor", request_serializer=platform.CreateProcessorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -973,7 +1066,7 @@ def update_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_processor" not in self._stubs: - self._stubs["update_processor"] = self.grpc_channel.unary_unary( + self._stubs["update_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/UpdateProcessor", request_serializer=platform.UpdateProcessorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1001,7 +1094,7 @@ def delete_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_processor" not in self._stubs: - self._stubs["delete_processor"] = self.grpc_channel.unary_unary( + self._stubs["delete_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/DeleteProcessor", request_serializer=platform.DeleteProcessorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1169,7 +1262,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: @@ -1185,7 +1278,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, @@ -1202,7 +1295,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, @@ -1219,7 +1312,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, @@ -1238,7 +1331,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-visionai/google/cloud/visionai_v1/services/app_platform/transports/rest.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/transports/rest.py index 8a838c3e6068..f7ac39bbab1c 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/transports/rest.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/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, @@ -281,8 +289,11 @@ def post_update_processor(self, response): def pre_add_application_stream_input( self, request: platform.AddApplicationStreamInputRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.AddApplicationStreamInputRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.AddApplicationStreamInputRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for add_application_stream_input Override in a subclass to manipulate the request or metadata @@ -304,8 +315,10 @@ def post_add_application_stream_input( def pre_create_application( self, request: platform.CreateApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.CreateApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.CreateApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_application Override in a subclass to manipulate the request or metadata @@ -327,8 +340,11 @@ def post_create_application( def pre_create_application_instances( self, request: platform.CreateApplicationInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.CreateApplicationInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.CreateApplicationInstancesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_application_instances Override in a subclass to manipulate the request or metadata @@ -348,8 +364,10 @@ def post_create_application_instances( return response def pre_create_draft( - self, request: platform.CreateDraftRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.CreateDraftRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.CreateDraftRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.CreateDraftRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_draft Override in a subclass to manipulate the request or metadata @@ -371,8 +389,10 @@ def post_create_draft( def pre_create_processor( self, request: platform.CreateProcessorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.CreateProcessorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.CreateProcessorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_processor Override in a subclass to manipulate the request or metadata @@ -394,8 +414,10 @@ def post_create_processor( def pre_delete_application( self, request: platform.DeleteApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.DeleteApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.DeleteApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_application Override in a subclass to manipulate the request or metadata @@ -417,8 +439,11 @@ def post_delete_application( def pre_delete_application_instances( self, request: platform.DeleteApplicationInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.DeleteApplicationInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.DeleteApplicationInstancesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_application_instances Override in a subclass to manipulate the request or metadata @@ -438,8 +463,10 @@ def post_delete_application_instances( return response def pre_delete_draft( - self, request: platform.DeleteDraftRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.DeleteDraftRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.DeleteDraftRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.DeleteDraftRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_draft Override in a subclass to manipulate the request or metadata @@ -461,8 +488,10 @@ def post_delete_draft( def pre_delete_processor( self, request: platform.DeleteProcessorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.DeleteProcessorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.DeleteProcessorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_processor Override in a subclass to manipulate the request or metadata @@ -484,8 +513,10 @@ def post_delete_processor( def pre_deploy_application( self, request: platform.DeployApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.DeployApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.DeployApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for deploy_application Override in a subclass to manipulate the request or metadata @@ -507,8 +538,8 @@ def post_deploy_application( def pre_get_application( self, request: platform.GetApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.GetApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.GetApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_application Override in a subclass to manipulate the request or metadata @@ -528,8 +559,10 @@ def post_get_application( return response def pre_get_draft( - self, request: platform.GetDraftRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.GetDraftRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.GetDraftRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.GetDraftRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_draft Override in a subclass to manipulate the request or metadata @@ -547,8 +580,10 @@ def post_get_draft(self, response: platform.Draft) -> platform.Draft: return response def pre_get_instance( - self, request: platform.GetInstanceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.GetInstanceRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.GetInstanceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.GetInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_instance Override in a subclass to manipulate the request or metadata @@ -566,8 +601,10 @@ def post_get_instance(self, response: platform.Instance) -> platform.Instance: return response def pre_get_processor( - self, request: platform.GetProcessorRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.GetProcessorRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.GetProcessorRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.GetProcessorRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_processor Override in a subclass to manipulate the request or metadata @@ -587,8 +624,10 @@ def post_get_processor(self, response: platform.Processor) -> platform.Processor def pre_list_applications( self, request: platform.ListApplicationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.ListApplicationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.ListApplicationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_applications Override in a subclass to manipulate the request or metadata @@ -608,8 +647,10 @@ def post_list_applications( return response def pre_list_drafts( - self, request: platform.ListDraftsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.ListDraftsRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.ListDraftsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.ListDraftsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_drafts Override in a subclass to manipulate the request or metadata @@ -631,8 +672,8 @@ def post_list_drafts( def pre_list_instances( self, request: platform.ListInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.ListInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.ListInstancesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_instances Override in a subclass to manipulate the request or metadata @@ -654,8 +695,10 @@ def post_list_instances( def pre_list_prebuilt_processors( self, request: platform.ListPrebuiltProcessorsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.ListPrebuiltProcessorsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.ListPrebuiltProcessorsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_prebuilt_processors Override in a subclass to manipulate the request or metadata @@ -677,8 +720,8 @@ def post_list_prebuilt_processors( def pre_list_processors( self, request: platform.ListProcessorsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.ListProcessorsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.ListProcessorsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_processors Override in a subclass to manipulate the request or metadata @@ -700,8 +743,11 @@ def post_list_processors( def pre_remove_application_stream_input( self, request: platform.RemoveApplicationStreamInputRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.RemoveApplicationStreamInputRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.RemoveApplicationStreamInputRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for remove_application_stream_input Override in a subclass to manipulate the request or metadata @@ -723,8 +769,10 @@ def post_remove_application_stream_input( def pre_undeploy_application( self, request: platform.UndeployApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.UndeployApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.UndeployApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for undeploy_application Override in a subclass to manipulate the request or metadata @@ -746,8 +794,10 @@ def post_undeploy_application( def pre_update_application( self, request: platform.UpdateApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.UpdateApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.UpdateApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_application Override in a subclass to manipulate the request or metadata @@ -769,8 +819,11 @@ def post_update_application( def pre_update_application_instances( self, request: platform.UpdateApplicationInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.UpdateApplicationInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.UpdateApplicationInstancesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_application_instances Override in a subclass to manipulate the request or metadata @@ -792,8 +845,11 @@ def post_update_application_instances( def pre_update_application_stream_input( self, request: platform.UpdateApplicationStreamInputRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.UpdateApplicationStreamInputRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.UpdateApplicationStreamInputRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_application_stream_input Override in a subclass to manipulate the request or metadata @@ -813,8 +869,10 @@ def post_update_application_stream_input( return response def pre_update_draft( - self, request: platform.UpdateDraftRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.UpdateDraftRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.UpdateDraftRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.UpdateDraftRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_draft Override in a subclass to manipulate the request or metadata @@ -836,8 +894,10 @@ def post_update_draft( def pre_update_processor( self, request: platform.UpdateProcessorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.UpdateProcessorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.UpdateProcessorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_processor Override in a subclass to manipulate the request or metadata @@ -859,8 +919,10 @@ def post_update_processor( 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 @@ -880,8 +942,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 @@ -901,8 +965,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 @@ -924,8 +990,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 @@ -1149,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]]] = (), ) -> operations_pb2.Operation: r"""Call the add application stream input method over HTTP. @@ -1161,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: ~.operations_pb2.Operation: @@ -1175,6 +1245,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseAddApplicationStreamInput._get_http_options() ) + request, metadata = self._interceptor.pre_add_application_stream_input( request, metadata ) @@ -1191,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.AddApplicationStreamInput", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "AddApplicationStreamInput", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppPlatformRestTransport._AddApplicationStreamInput._get_response( @@ -1212,7 +1310,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_application_stream_input(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.AppPlatformClient.add_application_stream_input", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "AddApplicationStreamInput", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateApplication( @@ -1250,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create application method over HTTP. @@ -1260,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: ~.operations_pb2.Operation: @@ -1274,6 +1396,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseCreateApplication._get_http_options() ) + request, metadata = self._interceptor.pre_create_application( request, metadata ) @@ -1290,6 +1413,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.CreateApplication", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "CreateApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._CreateApplication._get_response( self._host, @@ -1309,7 +1459,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_application(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.AppPlatformClient.create_application", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "CreateApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateApplicationInstances( @@ -1348,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create application instances method over HTTP. @@ -1360,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: ~.operations_pb2.Operation: @@ -1374,6 +1548,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseCreateApplicationInstances._get_http_options() ) + request, metadata = self._interceptor.pre_create_application_instances( request, metadata ) @@ -1390,6 +1565,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.CreateApplicationInstances", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "CreateApplicationInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppPlatformRestTransport._CreateApplicationInstances._get_response( @@ -1411,7 +1613,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_application_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.AppPlatformClient.create_application_instances", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "CreateApplicationInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateDraft( @@ -1449,7 +1673,7 @@ 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 draft method over HTTP. @@ -1459,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: ~.operations_pb2.Operation: @@ -1473,6 +1699,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseCreateDraft._get_http_options() ) + request, metadata = self._interceptor.pre_create_draft(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseCreateDraft._get_transcoded_request( @@ -1493,6 +1720,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.CreateDraft", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "CreateDraft", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._CreateDraft._get_response( self._host, @@ -1512,7 +1766,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_draft(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.AppPlatformClient.create_draft", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "CreateDraft", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateProcessor( @@ -1550,7 +1826,7 @@ 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 processor method over HTTP. @@ -1560,8 +1836,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1574,6 +1852,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseCreateProcessor._get_http_options() ) + request, metadata = self._interceptor.pre_create_processor( request, metadata ) @@ -1590,6 +1869,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.CreateProcessor", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "CreateProcessor", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._CreateProcessor._get_response( self._host, @@ -1609,7 +1915,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_processor(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.AppPlatformClient.create_processor", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "CreateProcessor", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteApplication( @@ -1646,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete application method over HTTP. @@ -1656,8 +1984,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1670,6 +2000,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseDeleteApplication._get_http_options() ) + request, metadata = self._interceptor.pre_delete_application( request, metadata ) @@ -1682,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.DeleteApplication", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "DeleteApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._DeleteApplication._get_response( self._host, @@ -1700,7 +2058,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_application(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.AppPlatformClient.delete_application", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "DeleteApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteApplicationInstances( @@ -1739,7 +2119,7 @@ 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 application instances method over HTTP. @@ -1751,8 +2131,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1765,6 +2147,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseDeleteApplicationInstances._get_http_options() ) + request, metadata = self._interceptor.pre_delete_application_instances( request, metadata ) @@ -1781,6 +2164,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.DeleteApplicationInstances", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "DeleteApplicationInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppPlatformRestTransport._DeleteApplicationInstances._get_response( @@ -1802,7 +2212,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_application_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.AppPlatformClient.delete_application_instances", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "DeleteApplicationInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteDraft( @@ -1839,7 +2271,7 @@ 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 draft method over HTTP. @@ -1849,8 +2281,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1863,6 +2297,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseDeleteDraft._get_http_options() ) + request, metadata = self._interceptor.pre_delete_draft(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseDeleteDraft._get_transcoded_request( @@ -1877,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.DeleteDraft", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "DeleteDraft", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._DeleteDraft._get_response( self._host, @@ -1895,7 +2357,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_draft(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.AppPlatformClient.delete_draft", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "DeleteDraft", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteProcessor( @@ -1932,7 +2416,7 @@ 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 processor method over HTTP. @@ -1942,8 +2426,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1956,6 +2442,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseDeleteProcessor._get_http_options() ) + request, metadata = self._interceptor.pre_delete_processor( request, metadata ) @@ -1968,6 +2455,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.DeleteProcessor", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "DeleteProcessor", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._DeleteProcessor._get_response( self._host, @@ -1986,7 +2500,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_processor(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.AppPlatformClient.delete_processor", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "DeleteProcessor", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeployApplication( @@ -2024,7 +2560,7 @@ 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 application method over HTTP. @@ -2034,8 +2570,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2048,6 +2586,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseDeployApplication._get_http_options() ) + request, metadata = self._interceptor.pre_deploy_application( request, metadata ) @@ -2064,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.visionai_v1.AppPlatformClient.DeployApplication", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "DeployApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._DeployApplication._get_response( self._host, @@ -2083,7 +2649,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_application(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.AppPlatformClient.deploy_application", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "DeployApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetApplication( @@ -2120,7 +2708,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Application: r"""Call the get application method over HTTP. @@ -2130,8 +2718,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.platform.Application: @@ -2141,6 +2731,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseGetApplication._get_http_options() ) + request, metadata = self._interceptor.pre_get_application(request, metadata) transcoded_request = _BaseAppPlatformRestTransport._BaseGetApplication._get_transcoded_request( http_options, request @@ -2151,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.visionai_v1.AppPlatformClient.GetApplication", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "GetApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._GetApplication._get_response( self._host, @@ -2171,7 +2789,29 @@ def __call__( pb_resp = platform.Application.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_application(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.Application.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.AppPlatformClient.get_application", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "GetApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDraft(_BaseAppPlatformRestTransport._BaseGetDraft, AppPlatformRestStub): @@ -2206,7 +2846,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Draft: r"""Call the get draft method over HTTP. @@ -2216,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: ~.platform.Draft: @@ -2227,6 +2869,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseGetDraft._get_http_options() ) + request, metadata = self._interceptor.pre_get_draft(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseGetDraft._get_transcoded_request( @@ -2241,6 +2884,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.GetDraft", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "GetDraft", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._GetDraft._get_response( self._host, @@ -2261,7 +2931,29 @@ def __call__( pb_resp = platform.Draft.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_draft(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.Draft.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.AppPlatformClient.get_draft", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "GetDraft", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetInstance( @@ -2298,7 +2990,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Instance: r"""Call the get instance method over HTTP. @@ -2308,8 +3000,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.platform.Instance: @@ -2321,6 +3015,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseGetInstance._get_http_options() ) + request, metadata = self._interceptor.pre_get_instance(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseGetInstance._get_transcoded_request( @@ -2335,6 +3030,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.GetInstance", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "GetInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._GetInstance._get_response( self._host, @@ -2355,7 +3077,29 @@ def __call__( pb_resp = platform.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 = platform.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.visionai_v1.AppPlatformClient.get_instance", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "GetInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetProcessor( @@ -2392,7 +3136,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Processor: r"""Call the get processor method over HTTP. @@ -2402,8 +3146,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.platform.Processor: @@ -2415,6 +3161,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseGetProcessor._get_http_options() ) + request, metadata = self._interceptor.pre_get_processor(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseGetProcessor._get_transcoded_request( @@ -2429,6 +3176,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.GetProcessor", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "GetProcessor", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._GetProcessor._get_response( self._host, @@ -2449,7 +3223,29 @@ def __call__( pb_resp = platform.Processor.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_processor(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.Processor.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.AppPlatformClient.get_processor", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "GetProcessor", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListApplications( @@ -2486,7 +3282,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.ListApplicationsResponse: r"""Call the list applications method over HTTP. @@ -2497,8 +3293,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.platform.ListApplicationsResponse: @@ -2510,6 +3308,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListApplications._get_http_options() ) + request, metadata = self._interceptor.pre_list_applications( request, metadata ) @@ -2522,6 +3321,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.ListApplications", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "ListApplications", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListApplications._get_response( self._host, @@ -2542,7 +3368,31 @@ def __call__( pb_resp = platform.ListApplicationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_applications(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.ListApplicationsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.AppPlatformClient.list_applications", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "ListApplications", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDrafts( @@ -2579,7 +3429,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.ListDraftsResponse: r"""Call the list drafts method over HTTP. @@ -2590,8 +3440,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.platform.ListDraftsResponse: @@ -2603,6 +3455,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListDrafts._get_http_options() ) + request, metadata = self._interceptor.pre_list_drafts(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseListDrafts._get_transcoded_request( @@ -2617,6 +3470,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.ListDrafts", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "ListDrafts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListDrafts._get_response( self._host, @@ -2637,7 +3517,29 @@ def __call__( pb_resp = platform.ListDraftsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_drafts(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.ListDraftsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.AppPlatformClient.list_drafts", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "ListDrafts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListInstances( @@ -2674,7 +3576,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.ListInstancesResponse: r"""Call the list instances method over HTTP. @@ -2685,8 +3587,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.platform.ListInstancesResponse: @@ -2698,6 +3602,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListInstances._get_http_options() ) + request, metadata = self._interceptor.pre_list_instances(request, metadata) transcoded_request = _BaseAppPlatformRestTransport._BaseListInstances._get_transcoded_request( http_options, request @@ -2710,6 +3615,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.ListInstances", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "ListInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListInstances._get_response( self._host, @@ -2730,7 +3662,29 @@ def __call__( pb_resp = platform.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 = platform.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.visionai_v1.AppPlatformClient.list_instances", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "ListInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPrebuiltProcessors( @@ -2768,7 +3722,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.ListPrebuiltProcessorsResponse: r"""Call the list prebuilt processors method over HTTP. @@ -2779,8 +3733,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.platform.ListPrebuiltProcessorsResponse: @@ -2792,6 +3748,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListPrebuiltProcessors._get_http_options() ) + request, metadata = self._interceptor.pre_list_prebuilt_processors( request, metadata ) @@ -2808,6 +3765,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.ListPrebuiltProcessors", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "ListPrebuiltProcessors", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListPrebuiltProcessors._get_response( self._host, @@ -2829,7 +3813,31 @@ def __call__( pb_resp = platform.ListPrebuiltProcessorsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_prebuilt_processors(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.ListPrebuiltProcessorsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.AppPlatformClient.list_prebuilt_processors", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "ListPrebuiltProcessors", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProcessors( @@ -2866,7 +3874,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.ListProcessorsResponse: r"""Call the list processors method over HTTP. @@ -2877,8 +3885,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.platform.ListProcessorsResponse: @@ -2890,6 +3900,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListProcessors._get_http_options() ) + request, metadata = self._interceptor.pre_list_processors(request, metadata) transcoded_request = _BaseAppPlatformRestTransport._BaseListProcessors._get_transcoded_request( http_options, request @@ -2900,6 +3911,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.ListProcessors", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "ListProcessors", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListProcessors._get_response( self._host, @@ -2920,7 +3958,29 @@ def __call__( pb_resp = platform.ListProcessorsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_processors(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.ListProcessorsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.AppPlatformClient.list_processors", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "ListProcessors", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveApplicationStreamInput( @@ -2959,7 +4019,7 @@ 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 remove application stream input method over HTTP. @@ -2971,8 +4031,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2985,6 +4047,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseRemoveApplicationStreamInput._get_http_options() ) + request, metadata = self._interceptor.pre_remove_application_stream_input( request, metadata ) @@ -3001,6 +4064,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.RemoveApplicationStreamInput", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "RemoveApplicationStreamInput", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppPlatformRestTransport._RemoveApplicationStreamInput._get_response( @@ -3022,7 +4112,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_application_stream_input(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.AppPlatformClient.remove_application_stream_input", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "RemoveApplicationStreamInput", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UndeployApplication( @@ -3060,7 +4172,7 @@ 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 application method over HTTP. @@ -3071,8 +4183,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3085,6 +4199,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseUndeployApplication._get_http_options() ) + request, metadata = self._interceptor.pre_undeploy_application( request, metadata ) @@ -3101,6 +4216,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.UndeployApplication", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "UndeployApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._UndeployApplication._get_response( self._host, @@ -3120,7 +4262,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_application(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.AppPlatformClient.undeploy_application", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "UndeployApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateApplication( @@ -3158,7 +4322,7 @@ 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 application method over HTTP. @@ -3168,8 +4332,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3182,6 +4348,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseUpdateApplication._get_http_options() ) + request, metadata = self._interceptor.pre_update_application( request, metadata ) @@ -3198,6 +4365,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.UpdateApplication", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "UpdateApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._UpdateApplication._get_response( self._host, @@ -3217,7 +4411,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_application(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.AppPlatformClient.update_application", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "UpdateApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateApplicationInstances( @@ -3256,7 +4472,7 @@ 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 application instances method over HTTP. @@ -3268,8 +4484,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3282,6 +4500,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseUpdateApplicationInstances._get_http_options() ) + request, metadata = self._interceptor.pre_update_application_instances( request, metadata ) @@ -3298,6 +4517,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.UpdateApplicationInstances", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "UpdateApplicationInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppPlatformRestTransport._UpdateApplicationInstances._get_response( @@ -3319,7 +4565,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_application_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.AppPlatformClient.update_application_instances", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "UpdateApplicationInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateApplicationStreamInput( @@ -3358,7 +4626,7 @@ 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 application stream input method over HTTP. @@ -3370,8 +4638,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3384,6 +4654,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseUpdateApplicationStreamInput._get_http_options() ) + request, metadata = self._interceptor.pre_update_application_stream_input( request, metadata ) @@ -3400,6 +4671,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.UpdateApplicationStreamInput", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "UpdateApplicationStreamInput", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppPlatformRestTransport._UpdateApplicationStreamInput._get_response( @@ -3421,7 +4719,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_application_stream_input(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.AppPlatformClient.update_application_stream_input", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "UpdateApplicationStreamInput", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDraft( @@ -3459,7 +4779,7 @@ 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 draft method over HTTP. @@ -3469,8 +4789,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3483,6 +4805,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseUpdateDraft._get_http_options() ) + request, metadata = self._interceptor.pre_update_draft(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseUpdateDraft._get_transcoded_request( @@ -3503,6 +4826,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.UpdateDraft", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "UpdateDraft", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._UpdateDraft._get_response( self._host, @@ -3522,7 +4872,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_draft(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.AppPlatformClient.update_draft", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "UpdateDraft", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateProcessor( @@ -3560,7 +4932,7 @@ 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 processor method over HTTP. @@ -3570,8 +4942,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3584,6 +4958,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseUpdateProcessor._get_http_options() ) + request, metadata = self._interceptor.pre_update_processor( request, metadata ) @@ -3600,6 +4975,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.UpdateProcessor", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "UpdateProcessor", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._UpdateProcessor._get_response( self._host, @@ -3619,7 +5021,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_processor(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.AppPlatformClient.update_processor", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "UpdateProcessor", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -3884,7 +5308,7 @@ 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. @@ -3894,13 +5318,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 = ( _BaseAppPlatformRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -3917,6 +5344,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.CancelOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._CancelOperation._get_response( self._host, @@ -3973,7 +5427,7 @@ 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. @@ -3983,13 +5437,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 = ( _BaseAppPlatformRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -4002,6 +5459,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._DeleteOperation._get_response( self._host, @@ -4057,7 +5541,7 @@ 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. @@ -4067,8 +5551,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -4077,6 +5563,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseGetOperation._get_transcoded_request( @@ -4091,6 +5578,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._GetOperation._get_response( self._host, @@ -4110,6 +5624,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.visionai_v1.AppPlatformAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4150,7 +5685,7 @@ 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. @@ -4160,8 +5695,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -4170,6 +5707,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseAppPlatformRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -4180,6 +5718,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.AppPlatformClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListOperations._get_response( self._host, @@ -4199,6 +5764,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.visionai_v1.AppPlatformAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/async_client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/async_client.py index 13159bd850aa..7b2cdd7cd582 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/async_client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_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, HealthCheckServiceTransport from .transports.grpc_asyncio import HealthCheckServiceGrpcAsyncIOTransport +try: + from google.api_core import client_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 HealthCheckServiceAsyncClient: """HealthCheckService provides an interface for Vertex AI Vision @@ -264,13 +274,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.visionai_v1.HealthCheckServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1.HealthCheckService", + "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.visionai.v1.HealthCheckService", + "credentialsType": None, + }, + ) + async def health_check( self, request: Optional[Union[health_service.HealthCheckRequest, 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]]] = (), ) -> health_service.HealthCheckResponse: r"""HealthCheck method checks the health status of the cluster. @@ -307,8 +339,10 @@ async def sample_health_check(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.HealthCheckResponse: @@ -354,7 +388,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. @@ -365,8 +399,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. @@ -407,7 +443,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. @@ -418,8 +454,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. @@ -460,7 +498,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. @@ -476,8 +514,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 """ @@ -514,7 +554,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. @@ -529,8 +569,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 """ diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/client.py index 0f8e5214449b..ca4030762e7c 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_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.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 @@ -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,13 +668,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.visionai_v1.HealthCheckServiceClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1.HealthCheckService", + "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.visionai.v1.HealthCheckService", + "credentialsType": None, + }, + ) + def health_check( self, request: Optional[Union[health_service.HealthCheckRequest, 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]]] = (), ) -> health_service.HealthCheckResponse: r"""HealthCheck method checks the health status of the cluster. @@ -697,8 +734,10 @@ def sample_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.cloud.visionai_v1.types.HealthCheckResponse: @@ -755,7 +794,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. @@ -766,8 +805,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. @@ -808,7 +849,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. @@ -819,8 +860,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. @@ -861,7 +904,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. @@ -877,8 +920,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 """ @@ -915,7 +960,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. @@ -930,8 +975,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 """ diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/transports/grpc.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/transports/grpc.py index bd92d1e3455f..fa2c91f7de9b 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/transports/grpc.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_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.visionai_v1.types import health_service from .base import DEFAULT_CLIENT_INFO, HealthCheckServiceTransport +try: + from google.api_core import client_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.visionai.v1.HealthCheckService", + "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.visionai.v1.HealthCheckService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class HealthCheckServiceGrpcTransport(HealthCheckServiceTransport): """gRPC backend transport for HealthCheckService. @@ -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 @@ -261,7 +347,7 @@ def health_check( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "health_check" not in self._stubs: - self._stubs["health_check"] = self.grpc_channel.unary_unary( + self._stubs["health_check"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.HealthCheckService/HealthCheck", request_serializer=health_service.HealthCheckRequest.serialize, response_deserializer=health_service.HealthCheckResponse.deserialize, @@ -269,7 +355,7 @@ def health_check( return self._stubs["health_check"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -281,7 +367,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, @@ -298,7 +384,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, @@ -315,7 +401,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, @@ -334,7 +420,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-visionai/google/cloud/visionai_v1/services/health_check_service/transports/grpc_asyncio.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/transports/grpc_asyncio.py index 3ac0415dba00..d5559a1d4c09 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_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.visionai_v1.types import health_service from .base import DEFAULT_CLIENT_INFO, HealthCheckServiceTransport from .grpc import HealthCheckServiceGrpcTransport +try: + from google.api_core import client_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.visionai.v1.HealthCheckService", + "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.visionai.v1.HealthCheckService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class HealthCheckServiceGrpcAsyncIOTransport(HealthCheckServiceTransport): """gRPC AsyncIO backend transport for HealthCheckService. @@ -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 health_check( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "health_check" not in self._stubs: - self._stubs["health_check"] = self.grpc_channel.unary_unary( + self._stubs["health_check"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.HealthCheckService/HealthCheck", request_serializer=health_service.HealthCheckRequest.serialize, response_deserializer=health_service.HealthCheckResponse.deserialize, @@ -313,7 +398,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: @@ -329,7 +414,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, @@ -346,7 +431,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, @@ -363,7 +448,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, @@ -382,7 +467,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-visionai/google/cloud/visionai_v1/services/health_check_service/transports/rest.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/transports/rest.py index c224591dae3e..b40ac0368cb7 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/transports/rest.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_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, @@ -81,8 +89,10 @@ def post_health_check(self, response): def pre_health_check( self, request: health_service.HealthCheckRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[health_service.HealthCheckRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + health_service.HealthCheckRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for health_check Override in a subclass to manipulate the request or metadata @@ -104,8 +114,10 @@ def post_health_check( 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 @@ -125,8 +137,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 @@ -146,8 +160,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 @@ -169,8 +185,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 @@ -312,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]]] = (), ) -> health_service.HealthCheckResponse: r"""Call the health check method over HTTP. @@ -323,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: ~.health_service.HealthCheckResponse: @@ -336,6 +356,7 @@ def __call__( http_options = ( _BaseHealthCheckServiceRestTransport._BaseHealthCheck._get_http_options() ) + request, metadata = self._interceptor.pre_health_check(request, metadata) transcoded_request = _BaseHealthCheckServiceRestTransport._BaseHealthCheck._get_transcoded_request( http_options, request @@ -346,6 +367,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.HealthCheckServiceClient.HealthCheck", + extra={ + "serviceName": "google.cloud.visionai.v1.HealthCheckService", + "rpcName": "HealthCheck", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = HealthCheckServiceRestTransport._HealthCheck._get_response( self._host, @@ -366,7 +414,31 @@ def __call__( pb_resp = health_service.HealthCheckResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_health_check(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = health_service.HealthCheckResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.HealthCheckServiceClient.health_check", + extra={ + "serviceName": "google.cloud.visionai.v1.HealthCheckService", + "rpcName": "HealthCheck", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -419,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -429,13 +501,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 = ( _BaseHealthCheckServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -452,6 +527,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.HealthCheckServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.HealthCheckService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = HealthCheckServiceRestTransport._CancelOperation._get_response( self._host, @@ -509,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]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -519,13 +621,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 = ( _BaseHealthCheckServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -538,6 +643,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.HealthCheckServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.HealthCheckService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = HealthCheckServiceRestTransport._DeleteOperation._get_response( self._host, @@ -594,7 +726,7 @@ 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. @@ -604,8 +736,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -614,6 +748,7 @@ def __call__( http_options = ( _BaseHealthCheckServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseHealthCheckServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -624,6 +759,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.HealthCheckServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.HealthCheckService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = HealthCheckServiceRestTransport._GetOperation._get_response( self._host, @@ -643,6 +805,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.visionai_v1.HealthCheckServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.HealthCheckService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -684,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -694,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -704,6 +889,7 @@ def __call__( http_options = ( _BaseHealthCheckServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseHealthCheckServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -714,6 +900,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.HealthCheckServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1.HealthCheckService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = HealthCheckServiceRestTransport._ListOperations._get_response( self._host, @@ -733,6 +946,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.visionai_v1.HealthCheckServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1.HealthCheckService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/async_client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/async_client.py index 21056dfe8680..1b74cadbfd27 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/async_client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/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, LiveVideoAnalyticsTransport from .transports.grpc_asyncio import LiveVideoAnalyticsGrpcAsyncIOTransport +try: + from google.api_core import client_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 LiveVideoAnalyticsAsyncClient: """Service describing handlers for resources. The 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.visionai_v1.LiveVideoAnalyticsAsyncClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "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.visionai.v1.LiveVideoAnalytics", + "credentialsType": None, + }, + ) + async def list_public_operators( self, request: Optional[Union[lva_service.ListPublicOperatorsRequest, dict]] = None, @@ -284,7 +316,7 @@ async def list_public_operators( 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.ListPublicOperatorsAsyncPager: r"""ListPublicOperators returns all the operators in public registry. @@ -330,8 +362,10 @@ async def sample_list_public_operators(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.live_video_analytics.pagers.ListPublicOperatorsAsyncPager: @@ -407,7 +441,7 @@ async def resolve_operator_info( queries: Optional[MutableSequence[lva_service.OperatorQuery]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_service.ResolveOperatorInfoResponse: r"""ResolveOperatorInfo returns the operator information based on the request. @@ -461,8 +495,10 @@ async def sample_resolve_operator_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.visionai_v1.types.ResolveOperatorInfoResponse: @@ -525,7 +561,7 @@ async def list_operators( 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.ListOperatorsAsyncPager: r"""Lists Operators in a given project and location. @@ -570,8 +606,10 @@ async def sample_list_operators(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.live_video_analytics.pagers.ListOperatorsAsyncPager: @@ -646,7 +684,7 @@ async def get_operator( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_resources.Operator: r"""Gets details of a single Operator. @@ -687,8 +725,10 @@ async def sample_get_operator(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Operator: @@ -751,7 +791,7 @@ async def create_operator( operator_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 Operator in a given project and location. @@ -810,8 +850,10 @@ async def sample_create_operator(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -888,7 +930,7 @@ async def update_operator( 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 Operator. @@ -943,8 +985,10 @@ async def sample_update_operator(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1020,7 +1064,7 @@ async def delete_operator( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Operator. @@ -1065,8 +1109,10 @@ async def sample_delete_operator(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1145,7 +1191,7 @@ async def list_analyses( 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.ListAnalysesAsyncPager: r"""Lists Analyses in a given project and location. @@ -1190,8 +1236,10 @@ async def sample_list_analyses(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.live_video_analytics.pagers.ListAnalysesAsyncPager: @@ -1266,7 +1314,7 @@ async def get_analysis( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_resources.Analysis: r"""Gets details of a single Analysis. @@ -1307,8 +1355,10 @@ async def sample_get_analysis(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Analysis: @@ -1371,7 +1421,7 @@ async def create_analysis( analysis_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 Analysis in a given project and location. @@ -1430,8 +1480,10 @@ async def sample_create_analysis(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1508,7 +1560,7 @@ async def update_analysis( 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 Analysis. @@ -1563,8 +1615,10 @@ async def sample_update_analysis(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1640,7 +1694,7 @@ async def delete_analysis( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Analysis. @@ -1685,8 +1739,10 @@ async def sample_delete_analysis(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1765,7 +1821,7 @@ async def list_processes( 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.ListProcessesAsyncPager: r"""Lists Processes in a given project and location. @@ -1810,8 +1866,10 @@ async def sample_list_processes(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.live_video_analytics.pagers.ListProcessesAsyncPager: @@ -1886,7 +1944,7 @@ async def get_process( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_resources.Process: r"""Gets details of a single Process. @@ -1927,8 +1985,10 @@ async def sample_get_process(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Process: @@ -1991,7 +2051,7 @@ async def create_process( process_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 Process in a given project and location. @@ -2054,8 +2114,10 @@ async def sample_create_process(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2132,7 +2194,7 @@ async def update_process( 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 Process. @@ -2191,8 +2253,10 @@ async def sample_update_process(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2268,7 +2332,7 @@ async def delete_process( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Process. @@ -2313,8 +2377,10 @@ async def sample_delete_process(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2394,7 +2460,7 @@ async def batch_run_process( requests: Optional[MutableSequence[lva_service.CreateProcessRequest]] = None, retry: OptionalRetry = gapic_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"""Run all of the processes to "completion". Max time for each process is the LRO time limit. @@ -2456,8 +2522,10 @@ async def sample_batch_run_process(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2530,7 +2598,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. @@ -2541,8 +2609,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. @@ -2583,7 +2653,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. @@ -2594,8 +2664,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. @@ -2636,7 +2708,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. @@ -2652,8 +2724,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 """ @@ -2690,7 +2764,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. @@ -2705,8 +2779,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 """ diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/client.py index 9249645a2a0d..45f7465972b7 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/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 @@ -665,6 +675,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.visionai_v1.LiveVideoAnalyticsClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "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.visionai.v1.LiveVideoAnalytics", + "credentialsType": None, + }, + ) + def list_public_operators( self, request: Optional[Union[lva_service.ListPublicOperatorsRequest, dict]] = None, @@ -738,7 +775,7 @@ def list_public_operators( 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.ListPublicOperatorsPager: r"""ListPublicOperators returns all the operators in public registry. @@ -784,8 +821,10 @@ def sample_list_public_operators(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.live_video_analytics.pagers.ListPublicOperatorsPager: @@ -858,7 +897,7 @@ def resolve_operator_info( queries: Optional[MutableSequence[lva_service.OperatorQuery]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_service.ResolveOperatorInfoResponse: r"""ResolveOperatorInfo returns the operator information based on the request. @@ -912,8 +951,10 @@ def sample_resolve_operator_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.visionai_v1.types.ResolveOperatorInfoResponse: @@ -973,7 +1014,7 @@ def list_operators( 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.ListOperatorsPager: r"""Lists Operators in a given project and location. @@ -1018,8 +1059,10 @@ def sample_list_operators(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.live_video_analytics.pagers.ListOperatorsPager: @@ -1091,7 +1134,7 @@ def get_operator( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_resources.Operator: r"""Gets details of a single Operator. @@ -1132,8 +1175,10 @@ def sample_get_operator(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Operator: @@ -1193,7 +1238,7 @@ def create_operator( operator_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 Operator in a given project and location. @@ -1252,8 +1297,10 @@ def sample_create_operator(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1327,7 +1374,7 @@ def update_operator( 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 Operator. @@ -1382,8 +1429,10 @@ def sample_update_operator(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1456,7 +1505,7 @@ def delete_operator( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Operator. @@ -1501,8 +1550,10 @@ def sample_delete_operator(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1578,7 +1629,7 @@ def list_analyses( 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.ListAnalysesPager: r"""Lists Analyses in a given project and location. @@ -1623,8 +1674,10 @@ def sample_list_analyses(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.live_video_analytics.pagers.ListAnalysesPager: @@ -1696,7 +1749,7 @@ def get_analysis( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_resources.Analysis: r"""Gets details of a single Analysis. @@ -1737,8 +1790,10 @@ def sample_get_analysis(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Analysis: @@ -1798,7 +1853,7 @@ def create_analysis( analysis_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 Analysis in a given project and location. @@ -1857,8 +1912,10 @@ def sample_create_analysis(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1932,7 +1989,7 @@ def update_analysis( 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 Analysis. @@ -1987,8 +2044,10 @@ def sample_update_analysis(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2061,7 +2120,7 @@ def delete_analysis( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Analysis. @@ -2106,8 +2165,10 @@ def sample_delete_analysis(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2183,7 +2244,7 @@ def list_processes( 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.ListProcessesPager: r"""Lists Processes in a given project and location. @@ -2228,8 +2289,10 @@ def sample_list_processes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.live_video_analytics.pagers.ListProcessesPager: @@ -2301,7 +2364,7 @@ def get_process( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_resources.Process: r"""Gets details of a single Process. @@ -2342,8 +2405,10 @@ def sample_get_process(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Process: @@ -2403,7 +2468,7 @@ def create_process( process_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 Process in a given project and location. @@ -2466,8 +2531,10 @@ def sample_create_process(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2541,7 +2608,7 @@ def update_process( 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 Process. @@ -2600,8 +2667,10 @@ def sample_update_process(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2674,7 +2743,7 @@ def delete_process( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Process. @@ -2719,8 +2788,10 @@ def sample_delete_process(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2797,7 +2868,7 @@ def batch_run_process( requests: Optional[MutableSequence[lva_service.CreateProcessRequest]] = None, retry: OptionalRetry = gapic_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"""Run all of the processes to "completion". Max time for each process is the LRO time limit. @@ -2859,8 +2930,10 @@ def sample_batch_run_process(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2943,7 +3016,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. @@ -2954,8 +3027,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. @@ -2996,7 +3071,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. @@ -3007,8 +3082,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. @@ -3049,7 +3126,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. @@ -3065,8 +3142,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 """ @@ -3103,7 +3182,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. @@ -3118,8 +3197,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 """ diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/pagers.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/pagers.py index f19e538a9810..ea344017d17e 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/pagers.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/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 = lva_service.ListPublicOperatorsRequest(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 = lva_service.ListPublicOperatorsRequest(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 = lva_service.ListOperatorsRequest(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 = lva_service.ListOperatorsRequest(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 = lva_service.ListAnalysesRequest(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 = lva_service.ListAnalysesRequest(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 = lva_service.ListProcessesRequest(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 = lva_service.ListProcessesRequest(request) diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/transports/grpc.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/transports/grpc.py index 2f35b2804e26..2725fee93a5b 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/transports/grpc.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/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.visionai_v1.types import lva_resources, lva_service from .base import DEFAULT_CLIENT_INFO, LiveVideoAnalyticsTransport +try: + from google.api_core import client_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.visionai.v1.LiveVideoAnalytics", + "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.visionai.v1.LiveVideoAnalytics", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class LiveVideoAnalyticsGrpcTransport(LiveVideoAnalyticsTransport): """gRPC backend transport for LiveVideoAnalytics. @@ -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_public_operators( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_public_operators" not in self._stubs: - self._stubs["list_public_operators"] = self.grpc_channel.unary_unary( + self._stubs["list_public_operators"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/ListPublicOperators", request_serializer=lva_service.ListPublicOperatorsRequest.serialize, response_deserializer=lva_service.ListPublicOperatorsResponse.deserialize, @@ -308,7 +396,7 @@ def resolve_operator_info( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resolve_operator_info" not in self._stubs: - self._stubs["resolve_operator_info"] = self.grpc_channel.unary_unary( + self._stubs["resolve_operator_info"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/ResolveOperatorInfo", request_serializer=lva_service.ResolveOperatorInfoRequest.serialize, response_deserializer=lva_service.ResolveOperatorInfoResponse.deserialize, @@ -336,7 +424,7 @@ def list_operators( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operators" not in self._stubs: - self._stubs["list_operators"] = self.grpc_channel.unary_unary( + self._stubs["list_operators"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/ListOperators", request_serializer=lva_service.ListOperatorsRequest.serialize, response_deserializer=lva_service.ListOperatorsResponse.deserialize, @@ -362,7 +450,7 @@ def get_operator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operator" not in self._stubs: - self._stubs["get_operator"] = self.grpc_channel.unary_unary( + self._stubs["get_operator"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/GetOperator", request_serializer=lva_service.GetOperatorRequest.serialize, response_deserializer=lva_resources.Operator.deserialize, @@ -389,7 +477,7 @@ def create_operator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_operator" not in self._stubs: - self._stubs["create_operator"] = self.grpc_channel.unary_unary( + self._stubs["create_operator"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/CreateOperator", request_serializer=lva_service.CreateOperatorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -415,7 +503,7 @@ def update_operator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_operator" not in self._stubs: - self._stubs["update_operator"] = self.grpc_channel.unary_unary( + self._stubs["update_operator"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/UpdateOperator", request_serializer=lva_service.UpdateOperatorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -441,7 +529,7 @@ def delete_operator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operator" not in self._stubs: - self._stubs["delete_operator"] = self.grpc_channel.unary_unary( + self._stubs["delete_operator"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/DeleteOperator", request_serializer=lva_service.DeleteOperatorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -467,7 +555,7 @@ def list_analyses( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_analyses" not in self._stubs: - self._stubs["list_analyses"] = self.grpc_channel.unary_unary( + self._stubs["list_analyses"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/ListAnalyses", request_serializer=lva_service.ListAnalysesRequest.serialize, response_deserializer=lva_service.ListAnalysesResponse.deserialize, @@ -493,7 +581,7 @@ def get_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_analysis" not in self._stubs: - self._stubs["get_analysis"] = self.grpc_channel.unary_unary( + self._stubs["get_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/GetAnalysis", request_serializer=lva_service.GetAnalysisRequest.serialize, response_deserializer=lva_resources.Analysis.deserialize, @@ -520,7 +608,7 @@ def create_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_analysis" not in self._stubs: - self._stubs["create_analysis"] = self.grpc_channel.unary_unary( + self._stubs["create_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/CreateAnalysis", request_serializer=lva_service.CreateAnalysisRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -546,7 +634,7 @@ def update_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_analysis" not in self._stubs: - self._stubs["update_analysis"] = self.grpc_channel.unary_unary( + self._stubs["update_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/UpdateAnalysis", request_serializer=lva_service.UpdateAnalysisRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -572,7 +660,7 @@ def delete_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_analysis" not in self._stubs: - self._stubs["delete_analysis"] = self.grpc_channel.unary_unary( + self._stubs["delete_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/DeleteAnalysis", request_serializer=lva_service.DeleteAnalysisRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -600,7 +688,7 @@ def list_processes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_processes" not in self._stubs: - self._stubs["list_processes"] = self.grpc_channel.unary_unary( + self._stubs["list_processes"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/ListProcesses", request_serializer=lva_service.ListProcessesRequest.serialize, response_deserializer=lva_service.ListProcessesResponse.deserialize, @@ -626,7 +714,7 @@ def get_process( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_process" not in self._stubs: - self._stubs["get_process"] = self.grpc_channel.unary_unary( + self._stubs["get_process"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/GetProcess", request_serializer=lva_service.GetProcessRequest.serialize, response_deserializer=lva_resources.Process.deserialize, @@ -653,7 +741,7 @@ def create_process( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_process" not in self._stubs: - self._stubs["create_process"] = self.grpc_channel.unary_unary( + self._stubs["create_process"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/CreateProcess", request_serializer=lva_service.CreateProcessRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -679,7 +767,7 @@ def update_process( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_process" not in self._stubs: - self._stubs["update_process"] = self.grpc_channel.unary_unary( + self._stubs["update_process"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/UpdateProcess", request_serializer=lva_service.UpdateProcessRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -705,7 +793,7 @@ def delete_process( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_process" not in self._stubs: - self._stubs["delete_process"] = self.grpc_channel.unary_unary( + self._stubs["delete_process"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/DeleteProcess", request_serializer=lva_service.DeleteProcessRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -732,7 +820,7 @@ def batch_run_process( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_run_process" not in self._stubs: - self._stubs["batch_run_process"] = self.grpc_channel.unary_unary( + self._stubs["batch_run_process"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/BatchRunProcess", request_serializer=lva_service.BatchRunProcessRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -740,7 +828,7 @@ def batch_run_process( return self._stubs["batch_run_process"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -752,7 +840,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, @@ -769,7 +857,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, @@ -786,7 +874,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, @@ -805,7 +893,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-visionai/google/cloud/visionai_v1/services/live_video_analytics/transports/grpc_asyncio.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/transports/grpc_asyncio.py index ddf5373e05ea..c8dddc3b58b3 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/transports/grpc_asyncio.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/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.visionai_v1.types import lva_resources, lva_service from .base import DEFAULT_CLIENT_INFO, LiveVideoAnalyticsTransport from .grpc import LiveVideoAnalyticsGrpcTransport +try: + from google.api_core import client_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.visionai.v1.LiveVideoAnalytics", + "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.visionai.v1.LiveVideoAnalytics", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class LiveVideoAnalyticsGrpcAsyncIOTransport(LiveVideoAnalyticsTransport): """gRPC AsyncIO backend transport for LiveVideoAnalytics. @@ -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_public_operators( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_public_operators" not in self._stubs: - self._stubs["list_public_operators"] = self.grpc_channel.unary_unary( + self._stubs["list_public_operators"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/ListPublicOperators", request_serializer=lva_service.ListPublicOperatorsRequest.serialize, response_deserializer=lva_service.ListPublicOperatorsResponse.deserialize, @@ -318,7 +403,7 @@ def resolve_operator_info( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resolve_operator_info" not in self._stubs: - self._stubs["resolve_operator_info"] = self.grpc_channel.unary_unary( + self._stubs["resolve_operator_info"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/ResolveOperatorInfo", request_serializer=lva_service.ResolveOperatorInfoRequest.serialize, response_deserializer=lva_service.ResolveOperatorInfoResponse.deserialize, @@ -346,7 +431,7 @@ def list_operators( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operators" not in self._stubs: - self._stubs["list_operators"] = self.grpc_channel.unary_unary( + self._stubs["list_operators"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/ListOperators", request_serializer=lva_service.ListOperatorsRequest.serialize, response_deserializer=lva_service.ListOperatorsResponse.deserialize, @@ -372,7 +457,7 @@ def get_operator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operator" not in self._stubs: - self._stubs["get_operator"] = self.grpc_channel.unary_unary( + self._stubs["get_operator"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/GetOperator", request_serializer=lva_service.GetOperatorRequest.serialize, response_deserializer=lva_resources.Operator.deserialize, @@ -401,7 +486,7 @@ def create_operator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_operator" not in self._stubs: - self._stubs["create_operator"] = self.grpc_channel.unary_unary( + self._stubs["create_operator"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/CreateOperator", request_serializer=lva_service.CreateOperatorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -429,7 +514,7 @@ def update_operator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_operator" not in self._stubs: - self._stubs["update_operator"] = self.grpc_channel.unary_unary( + self._stubs["update_operator"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/UpdateOperator", request_serializer=lva_service.UpdateOperatorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -457,7 +542,7 @@ def delete_operator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operator" not in self._stubs: - self._stubs["delete_operator"] = self.grpc_channel.unary_unary( + self._stubs["delete_operator"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/DeleteOperator", request_serializer=lva_service.DeleteOperatorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -485,7 +570,7 @@ def list_analyses( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_analyses" not in self._stubs: - self._stubs["list_analyses"] = self.grpc_channel.unary_unary( + self._stubs["list_analyses"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/ListAnalyses", request_serializer=lva_service.ListAnalysesRequest.serialize, response_deserializer=lva_service.ListAnalysesResponse.deserialize, @@ -511,7 +596,7 @@ def get_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_analysis" not in self._stubs: - self._stubs["get_analysis"] = self.grpc_channel.unary_unary( + self._stubs["get_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/GetAnalysis", request_serializer=lva_service.GetAnalysisRequest.serialize, response_deserializer=lva_resources.Analysis.deserialize, @@ -540,7 +625,7 @@ def create_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_analysis" not in self._stubs: - self._stubs["create_analysis"] = self.grpc_channel.unary_unary( + self._stubs["create_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/CreateAnalysis", request_serializer=lva_service.CreateAnalysisRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -568,7 +653,7 @@ def update_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_analysis" not in self._stubs: - self._stubs["update_analysis"] = self.grpc_channel.unary_unary( + self._stubs["update_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/UpdateAnalysis", request_serializer=lva_service.UpdateAnalysisRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -596,7 +681,7 @@ def delete_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_analysis" not in self._stubs: - self._stubs["delete_analysis"] = self.grpc_channel.unary_unary( + self._stubs["delete_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/DeleteAnalysis", request_serializer=lva_service.DeleteAnalysisRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -624,7 +709,7 @@ def list_processes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_processes" not in self._stubs: - self._stubs["list_processes"] = self.grpc_channel.unary_unary( + self._stubs["list_processes"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/ListProcesses", request_serializer=lva_service.ListProcessesRequest.serialize, response_deserializer=lva_service.ListProcessesResponse.deserialize, @@ -650,7 +735,7 @@ def get_process( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_process" not in self._stubs: - self._stubs["get_process"] = self.grpc_channel.unary_unary( + self._stubs["get_process"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/GetProcess", request_serializer=lva_service.GetProcessRequest.serialize, response_deserializer=lva_resources.Process.deserialize, @@ -679,7 +764,7 @@ def create_process( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_process" not in self._stubs: - self._stubs["create_process"] = self.grpc_channel.unary_unary( + self._stubs["create_process"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/CreateProcess", request_serializer=lva_service.CreateProcessRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -707,7 +792,7 @@ def update_process( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_process" not in self._stubs: - self._stubs["update_process"] = self.grpc_channel.unary_unary( + self._stubs["update_process"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/UpdateProcess", request_serializer=lva_service.UpdateProcessRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -735,7 +820,7 @@ def delete_process( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_process" not in self._stubs: - self._stubs["delete_process"] = self.grpc_channel.unary_unary( + self._stubs["delete_process"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/DeleteProcess", request_serializer=lva_service.DeleteProcessRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -764,7 +849,7 @@ def batch_run_process( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_run_process" not in self._stubs: - self._stubs["batch_run_process"] = self.grpc_channel.unary_unary( + self._stubs["batch_run_process"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/BatchRunProcess", request_serializer=lva_service.BatchRunProcessRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -892,7 +977,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: @@ -908,7 +993,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, @@ -925,7 +1010,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, @@ -942,7 +1027,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, @@ -961,7 +1046,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-visionai/google/cloud/visionai_v1/services/live_video_analytics/transports/rest.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/transports/rest.py index dd2934cf70d9..03adc94ff4e8 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/transports/rest.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/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, @@ -217,8 +225,10 @@ def post_update_process(self, response): def pre_batch_run_process( self, request: lva_service.BatchRunProcessRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.BatchRunProcessRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.BatchRunProcessRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_run_process Override in a subclass to manipulate the request or metadata @@ -240,8 +250,10 @@ def post_batch_run_process( def pre_create_analysis( self, request: lva_service.CreateAnalysisRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.CreateAnalysisRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.CreateAnalysisRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_analysis Override in a subclass to manipulate the request or metadata @@ -263,8 +275,10 @@ def post_create_analysis( def pre_create_operator( self, request: lva_service.CreateOperatorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.CreateOperatorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.CreateOperatorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_operator Override in a subclass to manipulate the request or metadata @@ -286,8 +300,10 @@ def post_create_operator( def pre_create_process( self, request: lva_service.CreateProcessRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.CreateProcessRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.CreateProcessRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_process Override in a subclass to manipulate the request or metadata @@ -309,8 +325,10 @@ def post_create_process( def pre_delete_analysis( self, request: lva_service.DeleteAnalysisRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.DeleteAnalysisRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.DeleteAnalysisRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_analysis Override in a subclass to manipulate the request or metadata @@ -332,8 +350,10 @@ def post_delete_analysis( def pre_delete_operator( self, request: lva_service.DeleteOperatorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.DeleteOperatorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.DeleteOperatorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_operator Override in a subclass to manipulate the request or metadata @@ -355,8 +375,10 @@ def post_delete_operator( def pre_delete_process( self, request: lva_service.DeleteProcessRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.DeleteProcessRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.DeleteProcessRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_process Override in a subclass to manipulate the request or metadata @@ -378,8 +400,8 @@ def post_delete_process( def pre_get_analysis( self, request: lva_service.GetAnalysisRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.GetAnalysisRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[lva_service.GetAnalysisRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_analysis Override in a subclass to manipulate the request or metadata @@ -401,8 +423,8 @@ def post_get_analysis( def pre_get_operator( self, request: lva_service.GetOperatorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.GetOperatorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[lva_service.GetOperatorRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_operator Override in a subclass to manipulate the request or metadata @@ -424,8 +446,8 @@ def post_get_operator( def pre_get_process( self, request: lva_service.GetProcessRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.GetProcessRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[lva_service.GetProcessRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_process Override in a subclass to manipulate the request or metadata @@ -447,8 +469,10 @@ def post_get_process( def pre_list_analyses( self, request: lva_service.ListAnalysesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.ListAnalysesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.ListAnalysesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_analyses Override in a subclass to manipulate the request or metadata @@ -470,8 +494,10 @@ def post_list_analyses( def pre_list_operators( self, request: lva_service.ListOperatorsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.ListOperatorsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.ListOperatorsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operators Override in a subclass to manipulate the request or metadata @@ -493,8 +519,10 @@ def post_list_operators( def pre_list_processes( self, request: lva_service.ListProcessesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.ListProcessesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.ListProcessesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_processes Override in a subclass to manipulate the request or metadata @@ -516,8 +544,10 @@ def post_list_processes( def pre_list_public_operators( self, request: lva_service.ListPublicOperatorsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.ListPublicOperatorsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.ListPublicOperatorsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_public_operators Override in a subclass to manipulate the request or metadata @@ -539,8 +569,10 @@ def post_list_public_operators( def pre_resolve_operator_info( self, request: lva_service.ResolveOperatorInfoRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.ResolveOperatorInfoRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.ResolveOperatorInfoRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for resolve_operator_info Override in a subclass to manipulate the request or metadata @@ -562,8 +594,10 @@ def post_resolve_operator_info( def pre_update_analysis( self, request: lva_service.UpdateAnalysisRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.UpdateAnalysisRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.UpdateAnalysisRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_analysis Override in a subclass to manipulate the request or metadata @@ -585,8 +619,10 @@ def post_update_analysis( def pre_update_operator( self, request: lva_service.UpdateOperatorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.UpdateOperatorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.UpdateOperatorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_operator Override in a subclass to manipulate the request or metadata @@ -608,8 +644,10 @@ def post_update_operator( def pre_update_process( self, request: lva_service.UpdateProcessRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.UpdateProcessRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.UpdateProcessRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_process Override in a subclass to manipulate the request or metadata @@ -631,8 +669,10 @@ def post_update_process( 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 @@ -652,8 +692,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 @@ -673,8 +715,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 @@ -696,8 +740,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 @@ -923,7 +969,7 @@ 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 run process method over HTTP. @@ -934,8 +980,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -948,6 +996,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseBatchRunProcess._get_http_options() ) + request, metadata = self._interceptor.pre_batch_run_process( request, metadata ) @@ -964,6 +1013,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.LiveVideoAnalyticsClient.BatchRunProcess", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "BatchRunProcess", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._BatchRunProcess._get_response( self._host, @@ -983,7 +1059,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_run_process(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.LiveVideoAnalyticsClient.batch_run_process", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "BatchRunProcess", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateAnalysis( @@ -1022,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create analysis method over HTTP. @@ -1032,8 +1130,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1046,6 +1146,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseCreateAnalysis._get_http_options() ) + request, metadata = self._interceptor.pre_create_analysis(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseCreateAnalysis._get_transcoded_request( http_options, request @@ -1060,6 +1161,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.LiveVideoAnalyticsClient.CreateAnalysis", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "CreateAnalysis", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._CreateAnalysis._get_response( self._host, @@ -1079,7 +1207,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_analysis(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.LiveVideoAnalyticsClient.create_analysis", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "CreateAnalysis", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateOperator( @@ -1118,7 +1268,7 @@ 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 operator method over HTTP. @@ -1128,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: ~.operations_pb2.Operation: @@ -1142,6 +1294,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseCreateOperator._get_http_options() ) + request, metadata = self._interceptor.pre_create_operator(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseCreateOperator._get_transcoded_request( http_options, request @@ -1156,6 +1309,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.LiveVideoAnalyticsClient.CreateOperator", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "CreateOperator", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._CreateOperator._get_response( self._host, @@ -1175,7 +1355,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_operator(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.LiveVideoAnalyticsClient.create_operator", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "CreateOperator", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateProcess( @@ -1214,7 +1416,7 @@ 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 process method over HTTP. @@ -1224,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: @@ -1238,6 +1442,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseCreateProcess._get_http_options() ) + request, metadata = self._interceptor.pre_create_process(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseCreateProcess._get_transcoded_request( http_options, request @@ -1252,6 +1457,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.LiveVideoAnalyticsClient.CreateProcess", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "CreateProcess", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._CreateProcess._get_response( self._host, @@ -1271,7 +1503,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_process(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.LiveVideoAnalyticsClient.create_process", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "CreateProcess", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAnalysis( @@ -1309,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 delete analysis method over HTTP. @@ -1319,8 +1573,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1333,6 +1589,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseDeleteAnalysis._get_http_options() ) + request, metadata = self._interceptor.pre_delete_analysis(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseDeleteAnalysis._get_transcoded_request( http_options, request @@ -1343,6 +1600,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.LiveVideoAnalyticsClient.DeleteAnalysis", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "DeleteAnalysis", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._DeleteAnalysis._get_response( self._host, @@ -1361,7 +1645,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_analysis(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.LiveVideoAnalyticsClient.delete_analysis", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "DeleteAnalysis", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteOperator( @@ -1399,7 +1705,7 @@ 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 operator method over HTTP. @@ -1409,8 +1715,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1423,6 +1731,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseDeleteOperator._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operator(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseDeleteOperator._get_transcoded_request( http_options, request @@ -1433,6 +1742,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.LiveVideoAnalyticsClient.DeleteOperator", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "DeleteOperator", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._DeleteOperator._get_response( self._host, @@ -1451,7 +1787,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_operator(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.LiveVideoAnalyticsClient.delete_operator", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "DeleteOperator", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteProcess( @@ -1489,7 +1847,7 @@ 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 process method over HTTP. @@ -1499,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: ~.operations_pb2.Operation: @@ -1513,6 +1873,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseDeleteProcess._get_http_options() ) + request, metadata = self._interceptor.pre_delete_process(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseDeleteProcess._get_transcoded_request( http_options, request @@ -1523,6 +1884,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.LiveVideoAnalyticsClient.DeleteProcess", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "DeleteProcess", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._DeleteProcess._get_response( self._host, @@ -1541,7 +1929,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_process(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.LiveVideoAnalyticsClient.delete_process", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "DeleteProcess", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAnalysis( @@ -1579,7 +1989,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_resources.Analysis: r"""Call the get analysis method over HTTP. @@ -1589,8 +1999,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.lva_resources.Analysis: @@ -1602,6 +2014,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseGetAnalysis._get_http_options() ) + request, metadata = self._interceptor.pre_get_analysis(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseGetAnalysis._get_transcoded_request( http_options, request @@ -1612,6 +2025,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.LiveVideoAnalyticsClient.GetAnalysis", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "GetAnalysis", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._GetAnalysis._get_response( self._host, @@ -1632,7 +2072,29 @@ def __call__( pb_resp = lva_resources.Analysis.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_analysis(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = lva_resources.Analysis.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.LiveVideoAnalyticsClient.get_analysis", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "GetAnalysis", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetOperator( @@ -1670,7 +2132,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_resources.Operator: r"""Call the get operator method over HTTP. @@ -1680,8 +2142,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.lva_resources.Operator: @@ -1693,6 +2157,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseGetOperator._get_http_options() ) + request, metadata = self._interceptor.pre_get_operator(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseGetOperator._get_transcoded_request( http_options, request @@ -1703,6 +2168,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.LiveVideoAnalyticsClient.GetOperator", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "GetOperator", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._GetOperator._get_response( self._host, @@ -1723,7 +2215,29 @@ def __call__( pb_resp = lva_resources.Operator.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_operator(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = lva_resources.Operator.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.LiveVideoAnalyticsClient.get_operator", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "GetOperator", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetProcess( @@ -1760,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]]] = (), ) -> lva_resources.Process: r"""Call the get process method over HTTP. @@ -1770,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: ~.lva_resources.Process: @@ -1783,6 +2299,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseGetProcess._get_http_options() ) + request, metadata = self._interceptor.pre_get_process(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseGetProcess._get_transcoded_request( http_options, request @@ -1793,6 +2310,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.LiveVideoAnalyticsClient.GetProcess", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "GetProcess", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._GetProcess._get_response( self._host, @@ -1813,7 +2357,29 @@ def __call__( pb_resp = lva_resources.Process.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_process(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = lva_resources.Process.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.LiveVideoAnalyticsClient.get_process", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "GetProcess", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAnalyses( @@ -1851,7 +2417,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_service.ListAnalysesResponse: r"""Call the list analyses method over HTTP. @@ -1862,8 +2428,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.lva_service.ListAnalysesResponse: @@ -1875,6 +2443,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseListAnalyses._get_http_options() ) + request, metadata = self._interceptor.pre_list_analyses(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseListAnalyses._get_transcoded_request( http_options, request @@ -1885,6 +2454,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.LiveVideoAnalyticsClient.ListAnalyses", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "ListAnalyses", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._ListAnalyses._get_response( self._host, @@ -1905,7 +2501,31 @@ def __call__( pb_resp = lva_service.ListAnalysesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_analyses(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = lva_service.ListAnalysesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.LiveVideoAnalyticsClient.list_analyses", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "ListAnalyses", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListOperators( @@ -1943,7 +2563,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_service.ListOperatorsResponse: r"""Call the list operators method over HTTP. @@ -1954,8 +2574,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.lva_service.ListOperatorsResponse: @@ -1967,6 +2589,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseListOperators._get_http_options() ) + request, metadata = self._interceptor.pre_list_operators(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseListOperators._get_transcoded_request( http_options, request @@ -1977,6 +2600,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.LiveVideoAnalyticsClient.ListOperators", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "ListOperators", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._ListOperators._get_response( self._host, @@ -1997,7 +2647,31 @@ def __call__( pb_resp = lva_service.ListOperatorsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_operators(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = lva_service.ListOperatorsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.LiveVideoAnalyticsClient.list_operators", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "ListOperators", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProcesses( @@ -2035,7 +2709,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_service.ListProcessesResponse: r"""Call the list processes method over HTTP. @@ -2046,8 +2720,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.lva_service.ListProcessesResponse: @@ -2059,6 +2735,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseListProcesses._get_http_options() ) + request, metadata = self._interceptor.pre_list_processes(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseListProcesses._get_transcoded_request( http_options, request @@ -2069,6 +2746,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.LiveVideoAnalyticsClient.ListProcesses", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "ListProcesses", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._ListProcesses._get_response( self._host, @@ -2089,7 +2793,31 @@ def __call__( pb_resp = lva_service.ListProcessesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_processes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = lva_service.ListProcessesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.LiveVideoAnalyticsClient.list_processes", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "ListProcesses", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPublicOperators( @@ -2127,7 +2855,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_service.ListPublicOperatorsResponse: r"""Call the list public operators method over HTTP. @@ -2138,8 +2866,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.lva_service.ListPublicOperatorsResponse: @@ -2151,6 +2881,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseListPublicOperators._get_http_options() ) + request, metadata = self._interceptor.pre_list_public_operators( request, metadata ) @@ -2163,6 +2894,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.LiveVideoAnalyticsClient.ListPublicOperators", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "ListPublicOperators", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( LiveVideoAnalyticsRestTransport._ListPublicOperators._get_response( @@ -2185,7 +2943,31 @@ def __call__( pb_resp = lva_service.ListPublicOperatorsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_public_operators(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = lva_service.ListPublicOperatorsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.LiveVideoAnalyticsClient.list_public_operators", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "ListPublicOperators", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ResolveOperatorInfo( @@ -2224,7 +3006,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_service.ResolveOperatorInfoResponse: r"""Call the resolve operator info method over HTTP. @@ -2235,8 +3017,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.lva_service.ResolveOperatorInfoResponse: @@ -2248,6 +3032,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseResolveOperatorInfo._get_http_options() ) + request, metadata = self._interceptor.pre_resolve_operator_info( request, metadata ) @@ -2264,6 +3049,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.LiveVideoAnalyticsClient.ResolveOperatorInfo", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "ResolveOperatorInfo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( LiveVideoAnalyticsRestTransport._ResolveOperatorInfo._get_response( @@ -2287,7 +3099,31 @@ def __call__( pb_resp = lva_service.ResolveOperatorInfoResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_resolve_operator_info(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = lva_service.ResolveOperatorInfoResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.LiveVideoAnalyticsClient.resolve_operator_info", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "ResolveOperatorInfo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAnalysis( @@ -2326,7 +3162,7 @@ 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 analysis method over HTTP. @@ -2336,8 +3172,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2350,6 +3188,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseUpdateAnalysis._get_http_options() ) + request, metadata = self._interceptor.pre_update_analysis(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseUpdateAnalysis._get_transcoded_request( http_options, request @@ -2364,6 +3203,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.LiveVideoAnalyticsClient.UpdateAnalysis", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "UpdateAnalysis", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._UpdateAnalysis._get_response( self._host, @@ -2383,7 +3249,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_analysis(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.LiveVideoAnalyticsClient.update_analysis", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "UpdateAnalysis", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateOperator( @@ -2422,7 +3310,7 @@ 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 operator method over HTTP. @@ -2432,8 +3320,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2446,6 +3336,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseUpdateOperator._get_http_options() ) + request, metadata = self._interceptor.pre_update_operator(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseUpdateOperator._get_transcoded_request( http_options, request @@ -2460,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.visionai_v1.LiveVideoAnalyticsClient.UpdateOperator", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "UpdateOperator", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._UpdateOperator._get_response( self._host, @@ -2479,7 +3397,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_operator(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.LiveVideoAnalyticsClient.update_operator", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "UpdateOperator", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateProcess( @@ -2518,7 +3458,7 @@ 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 process method over HTTP. @@ -2528,8 +3468,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2542,6 +3484,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseUpdateProcess._get_http_options() ) + request, metadata = self._interceptor.pre_update_process(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseUpdateProcess._get_transcoded_request( http_options, request @@ -2556,6 +3499,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.LiveVideoAnalyticsClient.UpdateProcess", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "UpdateProcess", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._UpdateProcess._get_response( self._host, @@ -2575,7 +3545,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_process(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.LiveVideoAnalyticsClient.update_process", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "UpdateProcess", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -2772,7 +3764,7 @@ 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. @@ -2782,13 +3774,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 = ( _BaseLiveVideoAnalyticsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -2805,6 +3800,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.LiveVideoAnalyticsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._CancelOperation._get_response( self._host, @@ -2862,7 +3884,7 @@ 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. @@ -2872,13 +3894,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 = ( _BaseLiveVideoAnalyticsRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -2891,6 +3916,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.LiveVideoAnalyticsClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._DeleteOperation._get_response( self._host, @@ -2947,7 +3999,7 @@ 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. @@ -2957,8 +4009,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -2967,6 +4021,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -2977,6 +4032,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.LiveVideoAnalyticsClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._GetOperation._get_response( self._host, @@ -2996,6 +4078,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.visionai_v1.LiveVideoAnalyticsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3037,7 +4140,7 @@ 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. @@ -3047,8 +4150,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -3057,6 +4162,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -3067,6 +4173,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.LiveVideoAnalyticsClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._ListOperations._get_response( self._host, @@ -3086,6 +4219,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.visionai_v1.LiveVideoAnalyticsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/async_client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/async_client.py index 8acca5f7b137..43eb87908cda 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/async_client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_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 ( AsyncIterable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, StreamingServiceTransport from .transports.grpc_asyncio import StreamingServiceGrpcAsyncIOTransport +try: + from google.api_core import client_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 StreamingServiceAsyncClient: """Streaming service for receiving and sending packets.""" @@ -264,13 +274,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.visionai_v1.StreamingServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "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.visionai.v1.StreamingService", + "credentialsType": None, + }, + ) + def send_packets( self, requests: Optional[AsyncIterator[streaming_service.SendPacketsRequest]] = None, *, retry: OptionalRetry = 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[streaming_service.SendPacketsResponse]]: r"""Send packets to the series. @@ -316,8 +348,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.visionai_v1.types.SendPacketsResponse]: @@ -352,7 +386,7 @@ def receive_packets( *, retry: OptionalRetry = 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[streaming_service.ReceivePacketsResponse]]: r"""Receive packets from the series. @@ -399,8 +433,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.visionai_v1.types.ReceivePacketsResponse]: @@ -435,7 +471,7 @@ def receive_events( *, retry: OptionalRetry = 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[streaming_service.ReceiveEventsResponse]]: r"""Receive events given the stream name. @@ -481,8 +517,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.visionai_v1.types.ReceiveEventsResponse]: @@ -517,7 +555,7 @@ async def acquire_lease( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.Lease: r"""AcquireLease acquires a lease. @@ -553,8 +591,10 @@ async def sample_acquire_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.visionai_v1.types.Lease: @@ -598,7 +638,7 @@ async def renew_lease( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.Lease: r"""RenewLease renews a lease. @@ -633,8 +673,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.visionai_v1.types.Lease: @@ -678,7 +720,7 @@ async def release_lease( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.ReleaseLeaseResponse: r"""RleaseLease releases a lease. @@ -713,8 +755,10 @@ async def sample_release_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.visionai_v1.types.ReleaseLeaseResponse: @@ -758,7 +802,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. @@ -769,8 +813,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. @@ -811,7 +857,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. @@ -822,8 +868,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. @@ -864,7 +912,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. @@ -880,8 +928,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 """ @@ -918,7 +968,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. @@ -933,8 +983,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 """ diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/client.py index 33f8163fd896..ec2c0017dd81 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_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 ( @@ -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.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_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,13 +669,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.visionai_v1.StreamingServiceClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "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.visionai.v1.StreamingService", + "credentialsType": None, + }, + ) + def send_packets( self, requests: Optional[Iterator[streaming_service.SendPacketsRequest]] = None, *, retry: OptionalRetry = 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[streaming_service.SendPacketsResponse]: r"""Send packets to the series. @@ -707,8 +744,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.visionai_v1.types.SendPacketsResponse]: @@ -739,7 +778,7 @@ def receive_packets( *, retry: OptionalRetry = 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[streaming_service.ReceivePacketsResponse]: r"""Receive packets from the series. @@ -786,8 +825,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.visionai_v1.types.ReceivePacketsResponse]: @@ -818,7 +859,7 @@ def receive_events( *, retry: OptionalRetry = 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[streaming_service.ReceiveEventsResponse]: r"""Receive events given the stream name. @@ -864,8 +905,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.visionai_v1.types.ReceiveEventsResponse]: @@ -898,7 +941,7 @@ def acquire_lease( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.Lease: r"""AcquireLease acquires a lease. @@ -934,8 +977,10 @@ def sample_acquire_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.visionai_v1.types.Lease: @@ -977,7 +1022,7 @@ def renew_lease( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.Lease: r"""RenewLease renews a lease. @@ -1012,8 +1057,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.visionai_v1.types.Lease: @@ -1055,7 +1102,7 @@ def release_lease( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.ReleaseLeaseResponse: r"""RleaseLease releases a lease. @@ -1090,8 +1137,10 @@ def sample_release_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.visionai_v1.types.ReleaseLeaseResponse: @@ -1146,7 +1195,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. @@ -1157,8 +1206,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. @@ -1199,7 +1250,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. @@ -1210,8 +1261,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. @@ -1252,7 +1305,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. @@ -1268,8 +1321,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 """ @@ -1306,7 +1361,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. @@ -1321,8 +1376,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 """ diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/transports/grpc.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/transports/grpc.py index 092525adbc12..e5c086e0da5e 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/transports/grpc.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_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.visionai_v1.types import streaming_service from .base import DEFAULT_CLIENT_INFO, StreamingServiceTransport +try: + from google.api_core import client_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.visionai.v1.StreamingService", + "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.visionai.v1.StreamingService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StreamingServiceGrpcTransport(StreamingServiceTransport): """gRPC backend transport for StreamingService. @@ -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 send_packets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "send_packets" not in self._stubs: - self._stubs["send_packets"] = self.grpc_channel.stream_stream( + self._stubs["send_packets"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1.StreamingService/SendPackets", request_serializer=streaming_service.SendPacketsRequest.serialize, response_deserializer=streaming_service.SendPacketsResponse.deserialize, @@ -288,7 +374,7 @@ def receive_packets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "receive_packets" not in self._stubs: - self._stubs["receive_packets"] = self.grpc_channel.stream_stream( + self._stubs["receive_packets"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1.StreamingService/ReceivePackets", request_serializer=streaming_service.ReceivePacketsRequest.serialize, response_deserializer=streaming_service.ReceivePacketsResponse.deserialize, @@ -317,7 +403,7 @@ def receive_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "receive_events" not in self._stubs: - self._stubs["receive_events"] = self.grpc_channel.stream_stream( + self._stubs["receive_events"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1.StreamingService/ReceiveEvents", request_serializer=streaming_service.ReceiveEventsRequest.serialize, response_deserializer=streaming_service.ReceiveEventsResponse.deserialize, @@ -343,7 +429,7 @@ def acquire_lease( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "acquire_lease" not in self._stubs: - self._stubs["acquire_lease"] = self.grpc_channel.unary_unary( + self._stubs["acquire_lease"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamingService/AcquireLease", request_serializer=streaming_service.AcquireLeaseRequest.serialize, response_deserializer=streaming_service.Lease.deserialize, @@ -369,7 +455,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.visionai.v1.StreamingService/RenewLease", request_serializer=streaming_service.RenewLeaseRequest.serialize, response_deserializer=streaming_service.Lease.deserialize, @@ -397,7 +483,7 @@ def release_lease( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "release_lease" not in self._stubs: - self._stubs["release_lease"] = self.grpc_channel.unary_unary( + self._stubs["release_lease"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamingService/ReleaseLease", request_serializer=streaming_service.ReleaseLeaseRequest.serialize, response_deserializer=streaming_service.ReleaseLeaseResponse.deserialize, @@ -405,7 +491,7 @@ def release_lease( return self._stubs["release_lease"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -417,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, @@ -434,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, @@ -451,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, @@ -470,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, diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/transports/grpc_asyncio.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/transports/grpc_asyncio.py index fd6aa6dc1ccf..552df3174288 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_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.visionai_v1.types import streaming_service from .base import DEFAULT_CLIENT_INFO, StreamingServiceTransport from .grpc import StreamingServiceGrpcTransport +try: + from google.api_core import client_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.visionai.v1.StreamingService", + "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.visionai.v1.StreamingService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StreamingServiceGrpcAsyncIOTransport(StreamingServiceTransport): """gRPC AsyncIO backend transport for StreamingService. @@ -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 send_packets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "send_packets" not in self._stubs: - self._stubs["send_packets"] = self.grpc_channel.stream_stream( + self._stubs["send_packets"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1.StreamingService/SendPackets", request_serializer=streaming_service.SendPacketsRequest.serialize, response_deserializer=streaming_service.SendPacketsResponse.deserialize, @@ -297,7 +382,7 @@ def receive_packets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "receive_packets" not in self._stubs: - self._stubs["receive_packets"] = self.grpc_channel.stream_stream( + self._stubs["receive_packets"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1.StreamingService/ReceivePackets", request_serializer=streaming_service.ReceivePacketsRequest.serialize, response_deserializer=streaming_service.ReceivePacketsResponse.deserialize, @@ -326,7 +411,7 @@ def receive_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "receive_events" not in self._stubs: - self._stubs["receive_events"] = self.grpc_channel.stream_stream( + self._stubs["receive_events"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1.StreamingService/ReceiveEvents", request_serializer=streaming_service.ReceiveEventsRequest.serialize, response_deserializer=streaming_service.ReceiveEventsResponse.deserialize, @@ -354,7 +439,7 @@ def acquire_lease( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "acquire_lease" not in self._stubs: - self._stubs["acquire_lease"] = self.grpc_channel.unary_unary( + self._stubs["acquire_lease"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamingService/AcquireLease", request_serializer=streaming_service.AcquireLeaseRequest.serialize, response_deserializer=streaming_service.Lease.deserialize, @@ -382,7 +467,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.visionai.v1.StreamingService/RenewLease", request_serializer=streaming_service.RenewLeaseRequest.serialize, response_deserializer=streaming_service.Lease.deserialize, @@ -411,7 +496,7 @@ def release_lease( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "release_lease" not in self._stubs: - self._stubs["release_lease"] = self.grpc_channel.unary_unary( + self._stubs["release_lease"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamingService/ReleaseLease", request_serializer=streaming_service.ReleaseLeaseRequest.serialize, response_deserializer=streaming_service.ReleaseLeaseResponse.deserialize, @@ -479,7 +564,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: @@ -495,7 +580,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, @@ -512,7 +597,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, @@ -529,7 +614,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, @@ -548,7 +633,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-visionai/google/cloud/visionai_v1/services/streaming_service/transports/rest.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/transports/rest.py index ea660554efea..72884e194c76 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/transports/rest.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_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, @@ -97,8 +105,10 @@ def post_renew_lease(self, response): def pre_acquire_lease( self, request: streaming_service.AcquireLeaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streaming_service.AcquireLeaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streaming_service.AcquireLeaseRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for acquire_lease Override in a subclass to manipulate the request or metadata @@ -120,8 +130,10 @@ def post_acquire_lease( def pre_release_lease( self, request: streaming_service.ReleaseLeaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streaming_service.ReleaseLeaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streaming_service.ReleaseLeaseRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for release_lease Override in a subclass to manipulate the request or metadata @@ -143,8 +155,10 @@ def post_release_lease( def pre_renew_lease( self, request: streaming_service.RenewLeaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streaming_service.RenewLeaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streaming_service.RenewLeaseRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for renew_lease Override in a subclass to manipulate the request or metadata @@ -166,8 +180,10 @@ def post_renew_lease( 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 @@ -187,8 +203,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 @@ -208,8 +226,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 @@ -231,8 +251,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 @@ -373,7 +395,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.Lease: r"""Call the acquire lease method over HTTP. @@ -384,8 +406,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.streaming_service.Lease: @@ -395,6 +419,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseAcquireLease._get_http_options() ) + request, metadata = self._interceptor.pre_acquire_lease(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseAcquireLease._get_transcoded_request( http_options, request @@ -409,6 +434,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamingServiceClient.AcquireLease", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "rpcName": "AcquireLease", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._AcquireLease._get_response( self._host, @@ -430,7 +482,29 @@ def __call__( pb_resp = streaming_service.Lease.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_acquire_lease(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streaming_service.Lease.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.StreamingServiceClient.acquire_lease", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "rpcName": "AcquireLease", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ReceiveEvents( @@ -445,7 +519,7 @@ 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 ReceiveEvents is not available over REST transport" @@ -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]]] = (), ) -> rest_streaming.ResponseIterator: raise NotImplementedError( "Method ReceivePackets is not available over REST transport" @@ -504,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]]] = (), ) -> streaming_service.ReleaseLeaseResponse: r"""Call the release lease method over HTTP. @@ -514,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: ~.streaming_service.ReleaseLeaseResponse: @@ -525,6 +601,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseReleaseLease._get_http_options() ) + request, metadata = self._interceptor.pre_release_lease(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseReleaseLease._get_transcoded_request( http_options, request @@ -539,6 +616,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamingServiceClient.ReleaseLease", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "rpcName": "ReleaseLease", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._ReleaseLease._get_response( self._host, @@ -560,7 +664,31 @@ def __call__( pb_resp = streaming_service.ReleaseLeaseResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_release_lease(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streaming_service.ReleaseLeaseResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.StreamingServiceClient.release_lease", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "rpcName": "ReleaseLease", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RenewLease( @@ -598,7 +726,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.Lease: r"""Call the renew lease method over HTTP. @@ -608,8 +736,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.streaming_service.Lease: @@ -619,6 +749,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseRenewLease._get_http_options() ) + request, metadata = self._interceptor.pre_renew_lease(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseRenewLease._get_transcoded_request( http_options, request @@ -633,6 +764,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamingServiceClient.RenewLease", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "rpcName": "RenewLease", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._RenewLease._get_response( self._host, @@ -654,7 +812,29 @@ def __call__( pb_resp = streaming_service.Lease.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 = streaming_service.Lease.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.StreamingServiceClient.renew_lease", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "rpcName": "RenewLease", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SendPackets( @@ -669,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]]] = (), ) -> rest_streaming.ResponseIterator: raise NotImplementedError( "Method SendPackets is not available over REST transport" @@ -773,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -783,13 +963,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 = ( _BaseStreamingServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamingServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._CancelOperation._get_response( self._host, @@ -863,7 +1073,7 @@ 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. @@ -873,13 +1083,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 = ( _BaseStreamingServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -892,6 +1105,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamingServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._DeleteOperation._get_response( self._host, @@ -947,7 +1187,7 @@ 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. @@ -957,8 +1197,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -967,6 +1209,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -977,6 +1220,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamingServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._GetOperation._get_response( self._host, @@ -996,6 +1266,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.visionai_v1.StreamingServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1036,7 +1327,7 @@ 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. @@ -1046,8 +1337,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -1056,6 +1349,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1066,6 +1360,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamingServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._ListOperations._get_response( self._host, @@ -1085,6 +1406,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.visionai_v1.StreamingServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/async_client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/async_client.py index 886545a28528..a5bd17cfd43b 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/async_client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_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, StreamsServiceTransport from .transports.grpc_asyncio import StreamsServiceGrpcAsyncIOTransport +try: + from google.api_core import client_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 StreamsServiceAsyncClient: """Service describing handlers for resources. @@ -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.visionai_v1.StreamsServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "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.visionai.v1.StreamsService", + "credentialsType": None, + }, + ) + async def list_clusters( self, request: Optional[Union[streams_service.ListClustersRequest, dict]] = None, @@ -285,7 +317,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 Clusters in a given project and location. @@ -330,8 +362,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.visionai_v1.services.streams_service.pagers.ListClustersAsyncPager: @@ -406,7 +440,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]]] = (), ) -> common.Cluster: r"""Gets details of a single Cluster. @@ -447,8 +481,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.visionai_v1.types.Cluster: @@ -511,7 +547,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. @@ -570,8 +606,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: @@ -648,7 +686,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 parameters of a single Cluster. @@ -703,8 +741,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: @@ -780,7 +820,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. @@ -825,8 +865,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: @@ -905,7 +947,7 @@ async def list_streams( 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.ListStreamsAsyncPager: r"""Lists Streams in a given project and location. @@ -950,8 +992,10 @@ async def sample_list_streams(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.streams_service.pagers.ListStreamsAsyncPager: @@ -1026,7 +1070,7 @@ async def get_stream( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Stream: r"""Gets details of a single Stream. @@ -1067,8 +1111,10 @@ async def sample_get_stream(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Stream: @@ -1135,7 +1181,7 @@ async def create_stream( stream_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 Stream in a given project and location. @@ -1193,8 +1239,10 @@ async def sample_create_stream(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1272,7 +1320,7 @@ async def update_stream( 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 Stream. @@ -1327,8 +1375,10 @@ async def sample_update_stream(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1405,7 +1455,7 @@ async def delete_stream( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Stream. @@ -1450,8 +1500,10 @@ async def sample_delete_stream(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1533,7 +1585,7 @@ async def get_stream_thumbnail( gcs_object_name: Optional[str] = None, retry: OptionalRetry = gapic_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"""Gets the thumbnail (image snapshot) of a single Stream. @@ -1590,8 +1642,10 @@ async def sample_get_stream_thumbnail(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1667,7 +1721,7 @@ async def generate_stream_hls_token( stream: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.GenerateStreamHlsTokenResponse: r"""Generate the JWT auth token required to get the stream HLS contents. @@ -1710,8 +1764,10 @@ async def sample_generate_stream_hls_token(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.GenerateStreamHlsTokenResponse: @@ -1772,7 +1828,7 @@ async def list_events( 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.ListEventsAsyncPager: r"""Lists Events in a given project and location. @@ -1817,8 +1873,10 @@ async def sample_list_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.cloud.visionai_v1.services.streams_service.pagers.ListEventsAsyncPager: @@ -1893,7 +1951,7 @@ async def get_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]]] = (), ) -> streams_resources.Event: r"""Gets details of a single Event. @@ -1934,8 +1992,10 @@ async def sample_get_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.cloud.visionai_v1.types.Event: @@ -1996,7 +2056,7 @@ async def create_event( event_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 Event in a given project and location. @@ -2054,8 +2114,10 @@ async def sample_create_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.api_core.operation_async.AsyncOperation: @@ -2132,7 +2194,7 @@ async def update_event( 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 Event. @@ -2187,8 +2249,10 @@ async def sample_update_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.api_core.operation_async.AsyncOperation: @@ -2264,7 +2328,7 @@ async def delete_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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Event. @@ -2309,8 +2373,10 @@ async def sample_delete_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.api_core.operation_async.AsyncOperation: @@ -2389,7 +2455,7 @@ async def list_series( 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.ListSeriesAsyncPager: r"""Lists Series in a given project and location. @@ -2434,8 +2500,10 @@ async def sample_list_series(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.streams_service.pagers.ListSeriesAsyncPager: @@ -2510,7 +2578,7 @@ async def get_series( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Series: r"""Gets details of a single Series. @@ -2551,8 +2619,10 @@ async def sample_get_series(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Series: @@ -2613,7 +2683,7 @@ async def create_series( series_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 Series in a given project and location. @@ -2676,8 +2746,10 @@ async def sample_create_series(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2754,7 +2826,7 @@ async def update_series( 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 Event. @@ -2814,8 +2886,10 @@ async def sample_update_series(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2891,7 +2965,7 @@ async def delete_series( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Series. @@ -2936,8 +3010,10 @@ async def sample_delete_series(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3020,7 +3096,7 @@ async def materialize_channel( channel_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"""Materialize a channel. @@ -3081,8 +3157,10 @@ async def sample_materialize_channel(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3157,7 +3235,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. @@ -3168,8 +3246,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. @@ -3210,7 +3290,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. @@ -3221,8 +3301,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. @@ -3263,7 +3345,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. @@ -3279,8 +3361,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 """ @@ -3317,7 +3401,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. @@ -3332,8 +3416,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 """ diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/client.py index 0595104ccf2a..3c3c2e121e4e 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_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 @@ -690,6 +700,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( @@ -755,6 +769,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.visionai_v1.StreamsServiceClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "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.visionai.v1.StreamsService", + "credentialsType": None, + }, + ) + def list_clusters( self, request: Optional[Union[streams_service.ListClustersRequest, dict]] = None, @@ -762,7 +799,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 Clusters in a given project and location. @@ -807,8 +844,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.visionai_v1.services.streams_service.pagers.ListClustersPager: @@ -880,7 +919,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]]] = (), ) -> common.Cluster: r"""Gets details of a single Cluster. @@ -921,8 +960,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.visionai_v1.types.Cluster: @@ -982,7 +1023,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. @@ -1041,8 +1082,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: @@ -1116,7 +1159,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 parameters of a single Cluster. @@ -1171,8 +1214,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: @@ -1245,7 +1290,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. @@ -1290,8 +1335,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: @@ -1367,7 +1414,7 @@ def list_streams( 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.ListStreamsPager: r"""Lists Streams in a given project and location. @@ -1412,8 +1459,10 @@ def sample_list_streams(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.streams_service.pagers.ListStreamsPager: @@ -1485,7 +1534,7 @@ def get_stream( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Stream: r"""Gets details of a single Stream. @@ -1526,8 +1575,10 @@ def sample_get_stream(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Stream: @@ -1591,7 +1642,7 @@ def create_stream( stream_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 Stream in a given project and location. @@ -1649,8 +1700,10 @@ def sample_create_stream(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1725,7 +1778,7 @@ def update_stream( 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 Stream. @@ -1780,8 +1833,10 @@ def sample_update_stream(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1855,7 +1910,7 @@ def delete_stream( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Stream. @@ -1900,8 +1955,10 @@ def sample_delete_stream(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1980,7 +2037,7 @@ def get_stream_thumbnail( gcs_object_name: Optional[str] = None, retry: OptionalRetry = gapic_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"""Gets the thumbnail (image snapshot) of a single Stream. @@ -2037,8 +2094,10 @@ def sample_get_stream_thumbnail(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2111,7 +2170,7 @@ def generate_stream_hls_token( stream: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.GenerateStreamHlsTokenResponse: r"""Generate the JWT auth token required to get the stream HLS contents. @@ -2154,8 +2213,10 @@ def sample_generate_stream_hls_token(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.GenerateStreamHlsTokenResponse: @@ -2215,7 +2276,7 @@ def list_events( 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.ListEventsPager: r"""Lists Events in a given project and location. @@ -2260,8 +2321,10 @@ def sample_list_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.cloud.visionai_v1.services.streams_service.pagers.ListEventsPager: @@ -2333,7 +2396,7 @@ def get_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]]] = (), ) -> streams_resources.Event: r"""Gets details of a single Event. @@ -2374,8 +2437,10 @@ def sample_get_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.cloud.visionai_v1.types.Event: @@ -2433,7 +2498,7 @@ def create_event( event_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 Event in a given project and location. @@ -2491,8 +2556,10 @@ def sample_create_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.operation.Operation: @@ -2566,7 +2633,7 @@ def update_event( 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 Event. @@ -2621,8 +2688,10 @@ def sample_update_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.operation.Operation: @@ -2695,7 +2764,7 @@ def delete_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]]] = (), ) -> operation.Operation: r"""Deletes a single Event. @@ -2740,8 +2809,10 @@ def sample_delete_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.operation.Operation: @@ -2817,7 +2888,7 @@ def list_series( 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.ListSeriesPager: r"""Lists Series in a given project and location. @@ -2862,8 +2933,10 @@ def sample_list_series(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.streams_service.pagers.ListSeriesPager: @@ -2935,7 +3008,7 @@ def get_series( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Series: r"""Gets details of a single Series. @@ -2976,8 +3049,10 @@ def sample_get_series(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Series: @@ -3035,7 +3110,7 @@ def create_series( series_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 Series in a given project and location. @@ -3098,8 +3173,10 @@ def sample_create_series(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3173,7 +3250,7 @@ def update_series( 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 Event. @@ -3233,8 +3310,10 @@ def sample_update_series(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3307,7 +3386,7 @@ def delete_series( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Series. @@ -3352,8 +3431,10 @@ def sample_delete_series(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3433,7 +3514,7 @@ def materialize_channel( channel_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"""Materialize a channel. @@ -3494,8 +3575,10 @@ def sample_materialize_channel(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3580,7 +3663,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. @@ -3591,8 +3674,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. @@ -3633,7 +3718,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. @@ -3644,8 +3729,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. @@ -3686,7 +3773,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. @@ -3702,8 +3789,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 """ @@ -3740,7 +3829,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. @@ -3755,8 +3844,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 """ diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/pagers.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/pagers.py index 97a21bfb4d5c..173c167f9c65 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/pagers.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_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 = streams_service.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 = streams_service.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 = streams_service.ListStreamsRequest(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 = streams_service.ListStreamsRequest(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 = streams_service.ListEventsRequest(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 = streams_service.ListEventsRequest(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 = streams_service.ListSeriesRequest(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 = streams_service.ListSeriesRequest(request) diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/transports/grpc.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/transports/grpc.py index e51ffe95d003..adf5cd921dcf 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/transports/grpc.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_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.visionai_v1.types import common, streams_resources, streams_service from .base import DEFAULT_CLIENT_INFO, StreamsServiceTransport +try: + from google.api_core import client_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.visionai.v1.StreamsService", + "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.visionai.v1.StreamsService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StreamsServiceGrpcTransport(StreamsServiceTransport): """gRPC backend transport for StreamsService. @@ -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 @@ -278,7 +366,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.visionai.v1.StreamsService/ListClusters", request_serializer=streams_service.ListClustersRequest.serialize, response_deserializer=streams_service.ListClustersResponse.deserialize, @@ -304,7 +392,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.visionai.v1.StreamsService/GetCluster", request_serializer=streams_service.GetClusterRequest.serialize, response_deserializer=common.Cluster.deserialize, @@ -331,7 +419,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.visionai.v1.StreamsService/CreateCluster", request_serializer=streams_service.CreateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -357,7 +445,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.visionai.v1.StreamsService/UpdateCluster", request_serializer=streams_service.UpdateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -383,7 +471,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.visionai.v1.StreamsService/DeleteCluster", request_serializer=streams_service.DeleteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -411,7 +499,7 @@ def list_streams( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_streams" not in self._stubs: - self._stubs["list_streams"] = self.grpc_channel.unary_unary( + self._stubs["list_streams"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/ListStreams", request_serializer=streams_service.ListStreamsRequest.serialize, response_deserializer=streams_service.ListStreamsResponse.deserialize, @@ -437,7 +525,7 @@ def get_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_stream" not in self._stubs: - self._stubs["get_stream"] = self.grpc_channel.unary_unary( + self._stubs["get_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/GetStream", request_serializer=streams_service.GetStreamRequest.serialize, response_deserializer=streams_resources.Stream.deserialize, @@ -463,7 +551,7 @@ def create_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_stream" not in self._stubs: - self._stubs["create_stream"] = self.grpc_channel.unary_unary( + self._stubs["create_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/CreateStream", request_serializer=streams_service.CreateStreamRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -489,7 +577,7 @@ def update_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_stream" not in self._stubs: - self._stubs["update_stream"] = self.grpc_channel.unary_unary( + self._stubs["update_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/UpdateStream", request_serializer=streams_service.UpdateStreamRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -515,7 +603,7 @@ def delete_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_stream" not in self._stubs: - self._stubs["delete_stream"] = self.grpc_channel.unary_unary( + self._stubs["delete_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/DeleteStream", request_serializer=streams_service.DeleteStreamRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -544,7 +632,7 @@ def get_stream_thumbnail( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_stream_thumbnail" not in self._stubs: - self._stubs["get_stream_thumbnail"] = self.grpc_channel.unary_unary( + self._stubs["get_stream_thumbnail"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/GetStreamThumbnail", request_serializer=streams_service.GetStreamThumbnailRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -574,7 +662,7 @@ def generate_stream_hls_token( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_stream_hls_token" not in self._stubs: - self._stubs["generate_stream_hls_token"] = self.grpc_channel.unary_unary( + self._stubs["generate_stream_hls_token"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/GenerateStreamHlsToken", request_serializer=streams_service.GenerateStreamHlsTokenRequest.serialize, response_deserializer=streams_service.GenerateStreamHlsTokenResponse.deserialize, @@ -602,7 +690,7 @@ def list_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_events" not in self._stubs: - self._stubs["list_events"] = self.grpc_channel.unary_unary( + self._stubs["list_events"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/ListEvents", request_serializer=streams_service.ListEventsRequest.serialize, response_deserializer=streams_service.ListEventsResponse.deserialize, @@ -628,7 +716,7 @@ def get_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_event" not in self._stubs: - self._stubs["get_event"] = self.grpc_channel.unary_unary( + self._stubs["get_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/GetEvent", request_serializer=streams_service.GetEventRequest.serialize, response_deserializer=streams_resources.Event.deserialize, @@ -654,7 +742,7 @@ def create_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_event" not in self._stubs: - self._stubs["create_event"] = self.grpc_channel.unary_unary( + self._stubs["create_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/CreateEvent", request_serializer=streams_service.CreateEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -680,7 +768,7 @@ def update_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_event" not in self._stubs: - self._stubs["update_event"] = self.grpc_channel.unary_unary( + self._stubs["update_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/UpdateEvent", request_serializer=streams_service.UpdateEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -706,7 +794,7 @@ def delete_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_event" not in self._stubs: - self._stubs["delete_event"] = self.grpc_channel.unary_unary( + self._stubs["delete_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/DeleteEvent", request_serializer=streams_service.DeleteEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -734,7 +822,7 @@ def list_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_series" not in self._stubs: - self._stubs["list_series"] = self.grpc_channel.unary_unary( + self._stubs["list_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/ListSeries", request_serializer=streams_service.ListSeriesRequest.serialize, response_deserializer=streams_service.ListSeriesResponse.deserialize, @@ -760,7 +848,7 @@ def get_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_series" not in self._stubs: - self._stubs["get_series"] = self.grpc_channel.unary_unary( + self._stubs["get_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/GetSeries", request_serializer=streams_service.GetSeriesRequest.serialize, response_deserializer=streams_resources.Series.deserialize, @@ -786,7 +874,7 @@ def create_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_series" not in self._stubs: - self._stubs["create_series"] = self.grpc_channel.unary_unary( + self._stubs["create_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/CreateSeries", request_serializer=streams_service.CreateSeriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -812,7 +900,7 @@ def update_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_series" not in self._stubs: - self._stubs["update_series"] = self.grpc_channel.unary_unary( + self._stubs["update_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/UpdateSeries", request_serializer=streams_service.UpdateSeriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -838,7 +926,7 @@ def delete_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_series" not in self._stubs: - self._stubs["delete_series"] = self.grpc_channel.unary_unary( + self._stubs["delete_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/DeleteSeries", request_serializer=streams_service.DeleteSeriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -866,7 +954,7 @@ def materialize_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "materialize_channel" not in self._stubs: - self._stubs["materialize_channel"] = self.grpc_channel.unary_unary( + self._stubs["materialize_channel"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/MaterializeChannel", request_serializer=streams_service.MaterializeChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -874,7 +962,7 @@ def materialize_channel( return self._stubs["materialize_channel"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -886,7 +974,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, @@ -903,7 +991,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, @@ -920,7 +1008,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, @@ -939,7 +1027,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-visionai/google/cloud/visionai_v1/services/streams_service/transports/grpc_asyncio.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/transports/grpc_asyncio.py index 9643064c9501..9fa0ec853a08 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_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.visionai_v1.types import common, streams_resources, streams_service from .base import DEFAULT_CLIENT_INFO, StreamsServiceTransport from .grpc import StreamsServiceGrpcTransport +try: + from google.api_core import client_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.visionai.v1.StreamsService", + "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.visionai.v1.StreamsService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StreamsServiceGrpcAsyncIOTransport(StreamsServiceTransport): """gRPC AsyncIO backend transport for StreamsService. @@ -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. @@ -289,7 +374,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.visionai.v1.StreamsService/ListClusters", request_serializer=streams_service.ListClustersRequest.serialize, response_deserializer=streams_service.ListClustersResponse.deserialize, @@ -315,7 +400,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.visionai.v1.StreamsService/GetCluster", request_serializer=streams_service.GetClusterRequest.serialize, response_deserializer=common.Cluster.deserialize, @@ -344,7 +429,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.visionai.v1.StreamsService/CreateCluster", request_serializer=streams_service.CreateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -372,7 +457,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.visionai.v1.StreamsService/UpdateCluster", request_serializer=streams_service.UpdateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -400,7 +485,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.visionai.v1.StreamsService/DeleteCluster", request_serializer=streams_service.DeleteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -429,7 +514,7 @@ def list_streams( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_streams" not in self._stubs: - self._stubs["list_streams"] = self.grpc_channel.unary_unary( + self._stubs["list_streams"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/ListStreams", request_serializer=streams_service.ListStreamsRequest.serialize, response_deserializer=streams_service.ListStreamsResponse.deserialize, @@ -457,7 +542,7 @@ def get_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_stream" not in self._stubs: - self._stubs["get_stream"] = self.grpc_channel.unary_unary( + self._stubs["get_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/GetStream", request_serializer=streams_service.GetStreamRequest.serialize, response_deserializer=streams_resources.Stream.deserialize, @@ -485,7 +570,7 @@ def create_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_stream" not in self._stubs: - self._stubs["create_stream"] = self.grpc_channel.unary_unary( + self._stubs["create_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/CreateStream", request_serializer=streams_service.CreateStreamRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -513,7 +598,7 @@ def update_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_stream" not in self._stubs: - self._stubs["update_stream"] = self.grpc_channel.unary_unary( + self._stubs["update_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/UpdateStream", request_serializer=streams_service.UpdateStreamRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -541,7 +626,7 @@ def delete_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_stream" not in self._stubs: - self._stubs["delete_stream"] = self.grpc_channel.unary_unary( + self._stubs["delete_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/DeleteStream", request_serializer=streams_service.DeleteStreamRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -570,7 +655,7 @@ def get_stream_thumbnail( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_stream_thumbnail" not in self._stubs: - self._stubs["get_stream_thumbnail"] = self.grpc_channel.unary_unary( + self._stubs["get_stream_thumbnail"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/GetStreamThumbnail", request_serializer=streams_service.GetStreamThumbnailRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -600,7 +685,7 @@ def generate_stream_hls_token( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_stream_hls_token" not in self._stubs: - self._stubs["generate_stream_hls_token"] = self.grpc_channel.unary_unary( + self._stubs["generate_stream_hls_token"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/GenerateStreamHlsToken", request_serializer=streams_service.GenerateStreamHlsTokenRequest.serialize, response_deserializer=streams_service.GenerateStreamHlsTokenResponse.deserialize, @@ -629,7 +714,7 @@ def list_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_events" not in self._stubs: - self._stubs["list_events"] = self.grpc_channel.unary_unary( + self._stubs["list_events"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/ListEvents", request_serializer=streams_service.ListEventsRequest.serialize, response_deserializer=streams_service.ListEventsResponse.deserialize, @@ -657,7 +742,7 @@ def get_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_event" not in self._stubs: - self._stubs["get_event"] = self.grpc_channel.unary_unary( + self._stubs["get_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/GetEvent", request_serializer=streams_service.GetEventRequest.serialize, response_deserializer=streams_resources.Event.deserialize, @@ -685,7 +770,7 @@ def create_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_event" not in self._stubs: - self._stubs["create_event"] = self.grpc_channel.unary_unary( + self._stubs["create_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/CreateEvent", request_serializer=streams_service.CreateEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -713,7 +798,7 @@ def update_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_event" not in self._stubs: - self._stubs["update_event"] = self.grpc_channel.unary_unary( + self._stubs["update_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/UpdateEvent", request_serializer=streams_service.UpdateEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -741,7 +826,7 @@ def delete_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_event" not in self._stubs: - self._stubs["delete_event"] = self.grpc_channel.unary_unary( + self._stubs["delete_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/DeleteEvent", request_serializer=streams_service.DeleteEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -770,7 +855,7 @@ def list_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_series" not in self._stubs: - self._stubs["list_series"] = self.grpc_channel.unary_unary( + self._stubs["list_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/ListSeries", request_serializer=streams_service.ListSeriesRequest.serialize, response_deserializer=streams_service.ListSeriesResponse.deserialize, @@ -798,7 +883,7 @@ def get_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_series" not in self._stubs: - self._stubs["get_series"] = self.grpc_channel.unary_unary( + self._stubs["get_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/GetSeries", request_serializer=streams_service.GetSeriesRequest.serialize, response_deserializer=streams_resources.Series.deserialize, @@ -826,7 +911,7 @@ def create_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_series" not in self._stubs: - self._stubs["create_series"] = self.grpc_channel.unary_unary( + self._stubs["create_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/CreateSeries", request_serializer=streams_service.CreateSeriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -854,7 +939,7 @@ def update_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_series" not in self._stubs: - self._stubs["update_series"] = self.grpc_channel.unary_unary( + self._stubs["update_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/UpdateSeries", request_serializer=streams_service.UpdateSeriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -882,7 +967,7 @@ def delete_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_series" not in self._stubs: - self._stubs["delete_series"] = self.grpc_channel.unary_unary( + self._stubs["delete_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/DeleteSeries", request_serializer=streams_service.DeleteSeriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -910,7 +995,7 @@ def materialize_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "materialize_channel" not in self._stubs: - self._stubs["materialize_channel"] = self.grpc_channel.unary_unary( + self._stubs["materialize_channel"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/MaterializeChannel", request_serializer=streams_service.MaterializeChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1063,7 +1148,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: @@ -1079,7 +1164,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, @@ -1096,7 +1181,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, @@ -1113,7 +1198,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, @@ -1132,7 +1217,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-visionai/google/cloud/visionai_v1/services/streams_service/transports/rest.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/transports/rest.py index 1e62f921ef9a..f41c3b236278 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/transports/rest.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_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, @@ -257,8 +265,10 @@ def post_update_stream(self, response): def pre_create_cluster( self, request: streams_service.CreateClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.CreateClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.CreateClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_cluster Override in a subclass to manipulate the request or metadata @@ -280,8 +290,10 @@ def post_create_cluster( def pre_create_event( self, request: streams_service.CreateEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.CreateEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.CreateEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_event Override in a subclass to manipulate the request or metadata @@ -303,8 +315,10 @@ def post_create_event( def pre_create_series( self, request: streams_service.CreateSeriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.CreateSeriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.CreateSeriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_series Override in a subclass to manipulate the request or metadata @@ -326,8 +340,10 @@ def post_create_series( def pre_create_stream( self, request: streams_service.CreateStreamRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.CreateStreamRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.CreateStreamRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_stream Override in a subclass to manipulate the request or metadata @@ -349,8 +365,10 @@ def post_create_stream( def pre_delete_cluster( self, request: streams_service.DeleteClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.DeleteClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.DeleteClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_cluster Override in a subclass to manipulate the request or metadata @@ -372,8 +390,10 @@ def post_delete_cluster( def pre_delete_event( self, request: streams_service.DeleteEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.DeleteEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.DeleteEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_event Override in a subclass to manipulate the request or metadata @@ -395,8 +415,10 @@ def post_delete_event( def pre_delete_series( self, request: streams_service.DeleteSeriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.DeleteSeriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.DeleteSeriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_series Override in a subclass to manipulate the request or metadata @@ -418,8 +440,10 @@ def post_delete_series( def pre_delete_stream( self, request: streams_service.DeleteStreamRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.DeleteStreamRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.DeleteStreamRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_stream Override in a subclass to manipulate the request or metadata @@ -441,9 +465,10 @@ def post_delete_stream( def pre_generate_stream_hls_token( self, request: streams_service.GenerateStreamHlsTokenRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - streams_service.GenerateStreamHlsTokenRequest, Sequence[Tuple[str, str]] + streams_service.GenerateStreamHlsTokenRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for generate_stream_hls_token @@ -466,8 +491,10 @@ def post_generate_stream_hls_token( def pre_get_cluster( self, request: streams_service.GetClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.GetClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.GetClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_cluster Override in a subclass to manipulate the request or metadata @@ -487,8 +514,10 @@ def post_get_cluster(self, response: common.Cluster) -> common.Cluster: def pre_get_event( self, request: streams_service.GetEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.GetEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.GetEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_event Override in a subclass to manipulate the request or metadata @@ -510,8 +539,10 @@ def post_get_event( def pre_get_series( self, request: streams_service.GetSeriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.GetSeriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.GetSeriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_series Override in a subclass to manipulate the request or metadata @@ -533,8 +564,10 @@ def post_get_series( def pre_get_stream( self, request: streams_service.GetStreamRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.GetStreamRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.GetStreamRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_stream Override in a subclass to manipulate the request or metadata @@ -556,8 +589,11 @@ def post_get_stream( def pre_get_stream_thumbnail( self, request: streams_service.GetStreamThumbnailRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.GetStreamThumbnailRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.GetStreamThumbnailRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_stream_thumbnail Override in a subclass to manipulate the request or metadata @@ -579,8 +615,10 @@ def post_get_stream_thumbnail( def pre_list_clusters( self, request: streams_service.ListClustersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.ListClustersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.ListClustersRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_clusters Override in a subclass to manipulate the request or metadata @@ -602,8 +640,10 @@ def post_list_clusters( def pre_list_events( self, request: streams_service.ListEventsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.ListEventsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.ListEventsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_events Override in a subclass to manipulate the request or metadata @@ -625,8 +665,10 @@ def post_list_events( def pre_list_series( self, request: streams_service.ListSeriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.ListSeriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.ListSeriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_series Override in a subclass to manipulate the request or metadata @@ -648,8 +690,10 @@ def post_list_series( def pre_list_streams( self, request: streams_service.ListStreamsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.ListStreamsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.ListStreamsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_streams Override in a subclass to manipulate the request or metadata @@ -671,8 +715,11 @@ def post_list_streams( def pre_materialize_channel( self, request: streams_service.MaterializeChannelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.MaterializeChannelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.MaterializeChannelRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for materialize_channel Override in a subclass to manipulate the request or metadata @@ -694,8 +741,10 @@ def post_materialize_channel( def pre_update_cluster( self, request: streams_service.UpdateClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.UpdateClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.UpdateClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_cluster Override in a subclass to manipulate the request or metadata @@ -717,8 +766,10 @@ def post_update_cluster( def pre_update_event( self, request: streams_service.UpdateEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.UpdateEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.UpdateEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_event Override in a subclass to manipulate the request or metadata @@ -740,8 +791,10 @@ def post_update_event( def pre_update_series( self, request: streams_service.UpdateSeriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.UpdateSeriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.UpdateSeriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_series Override in a subclass to manipulate the request or metadata @@ -763,8 +816,10 @@ def post_update_series( def pre_update_stream( self, request: streams_service.UpdateStreamRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.UpdateStreamRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.UpdateStreamRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_stream Override in a subclass to manipulate the request or metadata @@ -786,8 +841,10 @@ def post_update_stream( 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 @@ -807,8 +864,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 @@ -828,8 +887,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 @@ -851,8 +912,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 @@ -1079,7 +1142,7 @@ 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. @@ -1089,8 +1152,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1103,6 +1168,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseCreateCluster._get_http_options() ) + request, metadata = self._interceptor.pre_create_cluster(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseCreateCluster._get_transcoded_request( http_options, request @@ -1117,6 +1183,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.CreateCluster", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "CreateCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._CreateCluster._get_response( self._host, @@ -1136,7 +1229,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.visionai_v1.StreamsServiceClient.create_cluster", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "CreateCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateEvent( @@ -1174,7 +1289,7 @@ 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 event method over HTTP. @@ -1184,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: ~.operations_pb2.Operation: @@ -1198,6 +1315,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseCreateEvent._get_http_options() ) + request, metadata = self._interceptor.pre_create_event(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseCreateEvent._get_transcoded_request( http_options, request @@ -1212,6 +1330,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.CreateEvent", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "CreateEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._CreateEvent._get_response( self._host, @@ -1231,7 +1376,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_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.StreamsServiceClient.create_event", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "CreateEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSeries( @@ -1269,7 +1436,7 @@ 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 series method over HTTP. @@ -1279,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: ~.operations_pb2.Operation: @@ -1293,6 +1462,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseCreateSeries._get_http_options() ) + request, metadata = self._interceptor.pre_create_series(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseCreateSeries._get_transcoded_request( http_options, request @@ -1307,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.CreateSeries", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "CreateSeries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._CreateSeries._get_response( self._host, @@ -1326,7 +1523,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_series(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.StreamsServiceClient.create_series", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "CreateSeries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateStream( @@ -1364,7 +1583,7 @@ 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 stream method over HTTP. @@ -1374,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: ~.operations_pb2.Operation: @@ -1388,6 +1609,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseCreateStream._get_http_options() ) + request, metadata = self._interceptor.pre_create_stream(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseCreateStream._get_transcoded_request( http_options, request @@ -1402,6 +1624,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.CreateStream", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "CreateStream", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._CreateStream._get_response( self._host, @@ -1421,7 +1670,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_stream(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.StreamsServiceClient.create_stream", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "CreateStream", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCluster( @@ -1458,7 +1729,7 @@ 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. @@ -1468,8 +1739,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1482,6 +1755,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseDeleteCluster._get_http_options() ) + request, metadata = self._interceptor.pre_delete_cluster(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseDeleteCluster._get_transcoded_request( http_options, request @@ -1492,6 +1766,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.DeleteCluster", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "DeleteCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._DeleteCluster._get_response( self._host, @@ -1510,7 +1811,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.visionai_v1.StreamsServiceClient.delete_cluster", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "DeleteCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteEvent( @@ -1547,7 +1870,7 @@ 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 event method over HTTP. @@ -1557,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: ~.operations_pb2.Operation: @@ -1571,6 +1896,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseDeleteEvent._get_http_options() ) + request, metadata = self._interceptor.pre_delete_event(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseDeleteEvent._get_transcoded_request( http_options, request @@ -1581,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.DeleteEvent", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "DeleteEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._DeleteEvent._get_response( self._host, @@ -1599,7 +1952,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_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.StreamsServiceClient.delete_event", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "DeleteEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteSeries( @@ -1636,7 +2011,7 @@ 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 series method over HTTP. @@ -1646,8 +2021,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1660,6 +2037,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseDeleteSeries._get_http_options() ) + request, metadata = self._interceptor.pre_delete_series(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseDeleteSeries._get_transcoded_request( http_options, request @@ -1670,6 +2048,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.DeleteSeries", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "DeleteSeries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._DeleteSeries._get_response( self._host, @@ -1688,7 +2093,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_series(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.StreamsServiceClient.delete_series", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "DeleteSeries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteStream( @@ -1725,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete stream method over HTTP. @@ -1735,8 +2162,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1749,6 +2178,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseDeleteStream._get_http_options() ) + request, metadata = self._interceptor.pre_delete_stream(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseDeleteStream._get_transcoded_request( http_options, request @@ -1759,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.DeleteStream", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "DeleteStream", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._DeleteStream._get_response( self._host, @@ -1777,7 +2234,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_stream(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.StreamsServiceClient.delete_stream", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "DeleteStream", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateStreamHlsToken( @@ -1816,7 +2295,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.GenerateStreamHlsTokenResponse: r"""Call the generate stream hls token method over HTTP. @@ -1827,8 +2306,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.streams_service.GenerateStreamHlsTokenResponse: @@ -1840,6 +2321,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGenerateStreamHlsToken._get_http_options() ) + request, metadata = self._interceptor.pre_generate_stream_hls_token( request, metadata ) @@ -1856,6 +2338,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.GenerateStreamHlsToken", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GenerateStreamHlsToken", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( StreamsServiceRestTransport._GenerateStreamHlsToken._get_response( @@ -1879,7 +2388,31 @@ def __call__( pb_resp = streams_service.GenerateStreamHlsTokenResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_stream_hls_token(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + streams_service.GenerateStreamHlsTokenResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.StreamsServiceClient.generate_stream_hls_token", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GenerateStreamHlsToken", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCluster( @@ -1916,7 +2449,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.Cluster: r"""Call the get cluster method over HTTP. @@ -1926,8 +2459,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.common.Cluster: @@ -1939,6 +2474,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetCluster._get_http_options() ) + request, metadata = self._interceptor.pre_get_cluster(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseGetCluster._get_transcoded_request( http_options, request @@ -1951,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 = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.GetCluster", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GetCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetCluster._get_response( self._host, @@ -1971,7 +2534,29 @@ def __call__( pb_resp = common.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 = common.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.visionai_v1.StreamsServiceClient.get_cluster", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GetCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEvent( @@ -2008,7 +2593,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Event: r"""Call the get event method over HTTP. @@ -2018,8 +2603,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.streams_resources.Event: @@ -2029,6 +2616,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetEvent._get_http_options() ) + request, metadata = self._interceptor.pre_get_event(request, metadata) transcoded_request = ( _BaseStreamsServiceRestTransport._BaseGetEvent._get_transcoded_request( @@ -2043,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.visionai_v1.StreamsServiceClient.GetEvent", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GetEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetEvent._get_response( self._host, @@ -2063,7 +2678,29 @@ def __call__( pb_resp = streams_resources.Event.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_resources.Event.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.StreamsServiceClient.get_event", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GetEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSeries( @@ -2100,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]]] = (), ) -> streams_resources.Series: r"""Call the get series method over HTTP. @@ -2110,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: ~.streams_resources.Series: @@ -2121,6 +2760,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetSeries._get_http_options() ) + request, metadata = self._interceptor.pre_get_series(request, metadata) transcoded_request = ( _BaseStreamsServiceRestTransport._BaseGetSeries._get_transcoded_request( @@ -2135,6 +2775,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.GetSeries", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GetSeries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetSeries._get_response( self._host, @@ -2155,7 +2822,29 @@ def __call__( pb_resp = streams_resources.Series.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_series(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_resources.Series.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.StreamsServiceClient.get_series", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GetSeries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetStream( @@ -2192,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]]] = (), ) -> streams_resources.Stream: r"""Call the get stream method over HTTP. @@ -2202,8 +2891,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.streams_resources.Stream: @@ -2219,6 +2910,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetStream._get_http_options() ) + request, metadata = self._interceptor.pre_get_stream(request, metadata) transcoded_request = ( _BaseStreamsServiceRestTransport._BaseGetStream._get_transcoded_request( @@ -2233,6 +2925,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.GetStream", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GetStream", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetStream._get_response( self._host, @@ -2253,7 +2972,29 @@ def __call__( pb_resp = streams_resources.Stream.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_stream(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_resources.Stream.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.StreamsServiceClient.get_stream", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GetStream", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetStreamThumbnail( @@ -2291,7 +3032,7 @@ 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 stream thumbnail method over HTTP. @@ -2302,8 +3043,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2316,6 +3059,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetStreamThumbnail._get_http_options() ) + request, metadata = self._interceptor.pre_get_stream_thumbnail( request, metadata ) @@ -2332,6 +3076,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.GetStreamThumbnail", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GetStreamThumbnail", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetStreamThumbnail._get_response( self._host, @@ -2351,7 +3122,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_stream_thumbnail(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.StreamsServiceClient.get_stream_thumbnail", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GetStreamThumbnail", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListClusters( @@ -2388,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]]] = (), ) -> streams_service.ListClustersResponse: r"""Call the list clusters method over HTTP. @@ -2399,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: ~.streams_service.ListClustersResponse: @@ -2412,6 +3207,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseListClusters._get_http_options() ) + request, metadata = self._interceptor.pre_list_clusters(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseListClusters._get_transcoded_request( http_options, request @@ -2422,6 +3218,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.ListClusters", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "ListClusters", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._ListClusters._get_response( self._host, @@ -2442,7 +3265,31 @@ def __call__( pb_resp = streams_service.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 = streams_service.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.visionai_v1.StreamsServiceClient.list_clusters", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "ListClusters", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEvents( @@ -2479,7 +3326,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.ListEventsResponse: r"""Call the list events method over HTTP. @@ -2490,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: ~.streams_service.ListEventsResponse: @@ -2503,6 +3352,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseListEvents._get_http_options() ) + request, metadata = self._interceptor.pre_list_events(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseListEvents._get_transcoded_request( http_options, request @@ -2515,6 +3365,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.ListEvents", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "ListEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._ListEvents._get_response( self._host, @@ -2535,7 +3412,31 @@ def __call__( pb_resp = streams_service.ListEventsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_events(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_service.ListEventsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.StreamsServiceClient.list_events", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "ListEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSeries( @@ -2572,7 +3473,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.ListSeriesResponse: r"""Call the list series method over HTTP. @@ -2583,8 +3484,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.streams_service.ListSeriesResponse: @@ -2596,6 +3499,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseListSeries._get_http_options() ) + request, metadata = self._interceptor.pre_list_series(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseListSeries._get_transcoded_request( http_options, request @@ -2608,6 +3512,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.ListSeries", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "ListSeries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._ListSeries._get_response( self._host, @@ -2628,7 +3559,31 @@ def __call__( pb_resp = streams_service.ListSeriesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_series(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_service.ListSeriesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.StreamsServiceClient.list_series", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "ListSeries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListStreams( @@ -2665,7 +3620,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.ListStreamsResponse: r"""Call the list streams method over HTTP. @@ -2676,8 +3631,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.streams_service.ListStreamsResponse: @@ -2689,6 +3646,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseListStreams._get_http_options() ) + request, metadata = self._interceptor.pre_list_streams(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseListStreams._get_transcoded_request( http_options, request @@ -2699,6 +3657,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.ListStreams", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "ListStreams", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._ListStreams._get_response( self._host, @@ -2719,7 +3704,31 @@ def __call__( pb_resp = streams_service.ListStreamsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_streams(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_service.ListStreamsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.StreamsServiceClient.list_streams", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "ListStreams", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _MaterializeChannel( @@ -2757,7 +3766,7 @@ 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 materialize channel method over HTTP. @@ -2767,8 +3776,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2781,6 +3792,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseMaterializeChannel._get_http_options() ) + request, metadata = self._interceptor.pre_materialize_channel( request, metadata ) @@ -2797,6 +3809,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.MaterializeChannel", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "MaterializeChannel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._MaterializeChannel._get_response( self._host, @@ -2816,7 +3855,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_materialize_channel(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.StreamsServiceClient.materialize_channel", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "MaterializeChannel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCluster( @@ -2854,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]]] = (), ) -> operations_pb2.Operation: r"""Call the update cluster method over HTTP. @@ -2864,8 +3925,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2878,6 +3941,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseUpdateCluster._get_http_options() ) + request, metadata = self._interceptor.pre_update_cluster(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseUpdateCluster._get_transcoded_request( http_options, request @@ -2892,6 +3956,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.UpdateCluster", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "UpdateCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._UpdateCluster._get_response( self._host, @@ -2911,7 +4002,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.visionai_v1.StreamsServiceClient.update_cluster", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "UpdateCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateEvent( @@ -2949,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]]] = (), ) -> operations_pb2.Operation: r"""Call the update event method over HTTP. @@ -2959,8 +4072,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2973,6 +4088,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseUpdateEvent._get_http_options() ) + request, metadata = self._interceptor.pre_update_event(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseUpdateEvent._get_transcoded_request( http_options, request @@ -2987,6 +4103,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.UpdateEvent", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "UpdateEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._UpdateEvent._get_response( self._host, @@ -3006,7 +4149,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_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.StreamsServiceClient.update_event", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "UpdateEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSeries( @@ -3044,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]]] = (), ) -> operations_pb2.Operation: r"""Call the update series method over HTTP. @@ -3054,8 +4219,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3068,6 +4235,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseUpdateSeries._get_http_options() ) + request, metadata = self._interceptor.pre_update_series(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseUpdateSeries._get_transcoded_request( http_options, request @@ -3082,6 +4250,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.UpdateSeries", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "UpdateSeries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._UpdateSeries._get_response( self._host, @@ -3101,7 +4296,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_series(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.StreamsServiceClient.update_series", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "UpdateSeries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateStream( @@ -3139,7 +4356,7 @@ 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 stream method over HTTP. @@ -3149,8 +4366,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3163,6 +4382,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseUpdateStream._get_http_options() ) + request, metadata = self._interceptor.pre_update_stream(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseUpdateStream._get_transcoded_request( http_options, request @@ -3177,6 +4397,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.UpdateStream", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "UpdateStream", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._UpdateStream._get_response( self._host, @@ -3196,7 +4443,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_stream(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.StreamsServiceClient.update_stream", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "UpdateStream", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -3437,7 +4706,7 @@ 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. @@ -3447,13 +4716,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 = ( _BaseStreamsServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -3470,6 +4742,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._CancelOperation._get_response( self._host, @@ -3526,7 +4825,7 @@ 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. @@ -3536,13 +4835,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 = ( _BaseStreamsServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -3555,6 +4857,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._DeleteOperation._get_response( self._host, @@ -3610,7 +4939,7 @@ 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. @@ -3620,8 +4949,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -3630,6 +4961,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -3640,6 +4972,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetOperation._get_response( self._host, @@ -3659,6 +5018,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.visionai_v1.StreamsServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3699,7 +5079,7 @@ 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. @@ -3709,8 +5089,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -3719,6 +5101,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -3729,6 +5112,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.StreamsServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._ListOperations._get_response( self._host, @@ -3748,6 +5158,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.visionai_v1.StreamsServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/async_client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/async_client.py index 1b30cf61711d..608cf03c4ea5 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/async_client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/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, @@ -63,6 +64,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, WarehouseTransport from .transports.grpc_asyncio import WarehouseGrpcAsyncIOTransport +try: + from google.api_core import client_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 WarehouseAsyncClient: """Service that manages media content + metadata for streaming.""" @@ -280,6 +290,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.visionai_v1.WarehouseAsyncClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "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.visionai.v1.Warehouse", + "credentialsType": None, + }, + ) + async def create_asset( self, request: Optional[Union[warehouse.CreateAssetRequest, dict]] = None, @@ -289,7 +321,7 @@ async def create_asset( asset_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]]] = (), ) -> warehouse.Asset: r"""Creates an asset inside corpus. @@ -352,8 +384,10 @@ async def sample_create_asset(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Asset: @@ -424,7 +458,7 @@ async def update_asset( 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]]] = (), ) -> warehouse.Asset: r"""Updates an asset inside corpus. @@ -474,8 +508,10 @@ async def sample_update_asset(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Asset: @@ -545,7 +581,7 @@ async def get_asset( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Reads an asset inside corpus. @@ -588,8 +624,10 @@ async def sample_get_asset(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Asset: @@ -655,7 +693,7 @@ async def list_assets( 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.ListAssetsAsyncPager: r"""Lists an list of assets inside corpus. @@ -700,8 +738,10 @@ async def sample_list_assets(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.warehouse.pagers.ListAssetsAsyncPager: @@ -776,7 +816,7 @@ async def delete_asset( name: Optional[str] = None, retry: OptionalRetry = gapic_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 asset inside corpus. @@ -823,8 +863,10 @@ async def sample_delete_asset(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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 upload_asset( *, retry: OptionalRetry = gapic_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"""Upload asset by specifing the asset Cloud Storage uri. For video warehouse, it requires users who call @@ -954,8 +996,10 @@ async def sample_upload_asset(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1012,7 +1056,7 @@ async def generate_retrieval_url( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.GenerateRetrievalUrlResponse: r"""Generates a signed url for downloading the asset. For video warehouse, please see comment of UploadAsset @@ -1052,8 +1096,10 @@ async def sample_generate_retrieval_url(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.GenerateRetrievalUrlResponse: @@ -1099,7 +1145,7 @@ async def analyze_asset( *, retry: OptionalRetry = gapic_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"""Analyze asset to power search capability. @@ -1139,8 +1185,10 @@ async def sample_analyze_asset(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1197,7 +1245,7 @@ async def index_asset( *, retry: OptionalRetry = gapic_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"""Index one asset for search. Supported corpus type: Corpus.Type.VIDEO_ON_DEMAND @@ -1238,8 +1286,10 @@ async def sample_index_asset(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1296,7 +1346,7 @@ async def remove_index_asset( *, retry: OptionalRetry = gapic_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"""Remove one asset's index data for search. Supported corpus type: Corpus.Type.VIDEO_ON_DEMAND @@ -1337,8 +1387,10 @@ async def sample_remove_index_asset(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1396,7 +1448,7 @@ async def view_indexed_assets( index: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ViewIndexedAssetsAsyncPager: r"""Lists assets inside an index. @@ -1442,8 +1494,10 @@ async def sample_view_indexed_assets(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.warehouse.pagers.ViewIndexedAssetsAsyncPager: @@ -1520,7 +1574,7 @@ async def create_index( index_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 an Index under the corpus. @@ -1589,8 +1643,10 @@ async def sample_create_index(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1667,7 +1723,7 @@ async def update_index( 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 an Index under the corpus. Users can perform a metadata-only update or trigger a full index rebuild with @@ -1730,8 +1786,10 @@ async def sample_update_index(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1807,7 +1865,7 @@ async def get_index( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Index: r"""Gets the details of a single Index under a Corpus. @@ -1850,8 +1908,10 @@ async def sample_get_index(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Index: @@ -1915,7 +1975,7 @@ async def list_indexes( 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.ListIndexesAsyncPager: r"""List all Indexes in a given Corpus. @@ -1960,8 +2020,10 @@ async def sample_list_indexes(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.warehouse.pagers.ListIndexesAsyncPager: @@ -2036,7 +2098,7 @@ async def delete_index( name: Optional[str] = None, retry: OptionalRetry = gapic_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 single Index. In order to delete an index, the caller must make sure that it is not deployed to any @@ -2085,8 +2147,10 @@ async def sample_delete_index(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2166,7 +2230,7 @@ async def create_corpus( corpus: Optional[warehouse.Corpus] = None, retry: OptionalRetry = gapic_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 corpus inside a project. @@ -2222,8 +2286,10 @@ async def sample_create_corpus(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2297,7 +2363,7 @@ async def get_corpus( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Corpus: r"""Gets corpus details inside a project. @@ -2340,8 +2406,10 @@ async def sample_get_corpus(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Corpus: @@ -2405,7 +2473,7 @@ async def update_corpus( 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]]] = (), ) -> warehouse.Corpus: r"""Updates a corpus in a project. @@ -2456,8 +2524,10 @@ async def sample_update_corpus(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Corpus: @@ -2524,7 +2594,7 @@ async def list_corpora( 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.ListCorporaAsyncPager: r"""Lists all corpora in a project. @@ -2568,8 +2638,10 @@ async def sample_list_corpora(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.warehouse.pagers.ListCorporaAsyncPager: @@ -2644,7 +2716,7 @@ async def delete_corpus( name: Optional[str] = None, retry: OptionalRetry = 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 corpus only if its empty. Returns empty response. @@ -2685,8 +2757,10 @@ async def sample_delete_corpus(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -2737,7 +2811,7 @@ async def analyze_corpus( *, retry: OptionalRetry = gapic_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"""Analyzes a corpus. @@ -2777,8 +2851,10 @@ async def sample_analyze_corpus(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2837,7 +2913,7 @@ async def create_data_schema( data_schema: Optional[warehouse.DataSchema] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Creates data schema inside corpus. @@ -2890,8 +2966,10 @@ async def sample_create_data_schema(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.DataSchema: @@ -2956,7 +3034,7 @@ async def update_data_schema( 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]]] = (), ) -> warehouse.DataSchema: r"""Updates data schema inside corpus. @@ -3008,8 +3086,10 @@ async def sample_update_data_schema(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.DataSchema: @@ -3075,7 +3155,7 @@ async def get_data_schema( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Gets data schema inside corpus. @@ -3119,8 +3199,10 @@ async def sample_get_data_schema(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.DataSchema: @@ -3182,7 +3264,7 @@ async def delete_data_schema( name: Optional[str] = None, retry: OptionalRetry = 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 data schema inside corpus. @@ -3222,8 +3304,10 @@ async def sample_delete_data_schema(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -3275,7 +3359,7 @@ async def list_data_schemas( 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.ListDataSchemasAsyncPager: r"""Lists a list of data schemas inside corpus. @@ -3320,8 +3404,10 @@ async def sample_list_data_schemas(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.warehouse.pagers.ListDataSchemasAsyncPager: @@ -3398,7 +3484,7 @@ async def create_annotation( annotation_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]]] = (), ) -> warehouse.Annotation: r"""Creates annotation inside asset. @@ -3460,8 +3546,10 @@ async def sample_create_annotation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Annotation: @@ -3527,7 +3615,7 @@ async def get_annotation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Reads annotation inside asset. @@ -3572,8 +3660,10 @@ async def sample_get_annotation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Annotation: @@ -3635,7 +3725,7 @@ async def list_annotations( 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.ListAnnotationsAsyncPager: r"""Lists a list of annotations inside asset. @@ -3680,8 +3770,10 @@ async def sample_list_annotations(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.warehouse.pagers.ListAnnotationsAsyncPager: @@ -3757,7 +3849,7 @@ async def update_annotation( 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]]] = (), ) -> warehouse.Annotation: r"""Updates annotation inside asset. @@ -3807,8 +3899,10 @@ async def sample_update_annotation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Annotation: @@ -3874,7 +3968,7 @@ async def delete_annotation( name: Optional[str] = None, retry: OptionalRetry = 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 annotation inside asset. @@ -3915,8 +4009,10 @@ async def sample_delete_annotation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -3967,7 +4063,7 @@ def ingest_asset( *, retry: OptionalRetry = 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[warehouse.IngestAssetResponse]]: r"""Ingests data for the asset. It is not allowed to ingest a data chunk which is already expired according @@ -4021,8 +4117,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.visionai_v1.types.IngestAssetResponse]: @@ -4055,7 +4153,7 @@ async def clip_asset( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ClipAssetResponse: r"""Supported by STREAM_VIDEO corpus type. Generates clips for downloading. The api takes in a time range, and generates a clip @@ -4096,8 +4194,10 @@ async def sample_clip_asset(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.ClipAssetResponse: @@ -4141,7 +4241,7 @@ async def generate_hls_uri( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.GenerateHlsUriResponse: r"""Generates a uri for an HLS manifest. The api takes in a collection of time ranges, and generates a URI for an @@ -4180,8 +4280,10 @@ async def sample_generate_hls_uri(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.GenerateHlsUriResponse: @@ -4227,7 +4329,7 @@ async def import_assets( *, retry: OptionalRetry = gapic_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 assets (images plus annotations) from a meta file on cloud storage. Each row in the meta file is @@ -4271,8 +4373,10 @@ async def sample_import_assets(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -4332,7 +4436,7 @@ async def create_search_config( search_config_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]]] = (), ) -> warehouse.SearchConfig: r"""Creates a search configuration inside a corpus. @@ -4411,8 +4515,10 @@ async def sample_create_search_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.cloud.visionai_v1.types.SearchConfig: @@ -4479,7 +4585,7 @@ async def update_search_config( 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]]] = (), ) -> warehouse.SearchConfig: r"""Updates a search configuration inside a corpus. @@ -4547,8 +4653,10 @@ async def sample_update_search_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.cloud.visionai_v1.types.SearchConfig: @@ -4614,7 +4722,7 @@ async def get_search_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Gets a search configuration inside a corpus. @@ -4658,8 +4766,10 @@ async def sample_get_search_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.cloud.visionai_v1.types.SearchConfig: @@ -4721,7 +4831,7 @@ async def delete_search_config( name: Optional[str] = None, retry: OptionalRetry = 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 search configuration inside a corpus. @@ -4766,8 +4876,10 @@ async def sample_delete_search_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -4819,7 +4931,7 @@ async def list_search_configs( 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.ListSearchConfigsAsyncPager: r"""Lists all search configurations inside a corpus. @@ -4865,8 +4977,10 @@ async def sample_list_search_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.visionai_v1.services.warehouse.pagers.ListSearchConfigsAsyncPager: @@ -4943,7 +5057,7 @@ async def create_search_hypernym( search_hypernym_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]]] = (), ) -> warehouse.SearchHypernym: r"""Creates a SearchHypernym inside a corpus. @@ -5003,8 +5117,10 @@ async def sample_create_search_hypernym(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.SearchHypernym: @@ -5073,7 +5189,7 @@ async def update_search_hypernym( 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]]] = (), ) -> warehouse.SearchHypernym: r"""Updates a SearchHypernym inside a corpus. @@ -5126,8 +5242,10 @@ async def sample_update_search_hypernym(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.SearchHypernym: @@ -5195,7 +5313,7 @@ async def get_search_hypernym( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchHypernym: r"""Gets a SearchHypernym inside a corpus. @@ -5240,8 +5358,10 @@ async def sample_get_search_hypernym(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.SearchHypernym: @@ -5305,7 +5425,7 @@ async def delete_search_hypernym( name: Optional[str] = None, retry: OptionalRetry = 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 SearchHypernym inside a corpus. @@ -5347,8 +5467,10 @@ async def sample_delete_search_hypernym(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -5400,7 +5522,7 @@ async def list_search_hypernyms( 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.ListSearchHypernymsAsyncPager: r"""Lists SearchHypernyms inside a corpus. @@ -5446,8 +5568,10 @@ async def sample_list_search_hypernyms(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.warehouse.pagers.ListSearchHypernymsAsyncPager: @@ -5521,7 +5645,7 @@ async def search_assets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchAssetsAsyncPager: r"""Search media asset. @@ -5558,8 +5682,10 @@ async def sample_search_assets(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.warehouse.pagers.SearchAssetsAsyncPager: @@ -5619,7 +5745,7 @@ async def search_index_endpoint( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchIndexEndpointAsyncPager: r"""Search a deployed index endpoint (IMAGE corpus type only). @@ -5662,8 +5788,10 @@ async def sample_search_index_endpoint(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.warehouse.pagers.SearchIndexEndpointAsyncPager: @@ -5728,7 +5856,7 @@ async def create_index_endpoint( index_endpoint_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 an IndexEndpoint. @@ -5798,8 +5926,10 @@ async def sample_create_index_endpoint(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -5876,7 +6006,7 @@ async def get_index_endpoint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.IndexEndpoint: r"""Gets an IndexEndpoint. @@ -5919,8 +6049,10 @@ async def sample_get_index_endpoint(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.IndexEndpoint: @@ -5981,7 +6113,7 @@ async def list_index_endpoints( 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.ListIndexEndpointsAsyncPager: r"""Lists all IndexEndpoints in a project. @@ -6026,8 +6158,10 @@ async def sample_list_index_endpoints(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.warehouse.pagers.ListIndexEndpointsAsyncPager: @@ -6103,7 +6237,7 @@ async def update_index_endpoint( 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 an IndexEndpoint. @@ -6160,8 +6294,10 @@ async def sample_update_index_endpoint(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -6238,7 +6374,7 @@ async def delete_index_endpoint( name: Optional[str] = None, retry: OptionalRetry = gapic_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 an IndexEndpoint. @@ -6284,8 +6420,10 @@ async def sample_delete_index_endpoint(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -6363,7 +6501,7 @@ async def deploy_index( *, retry: OptionalRetry = gapic_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 an Index to IndexEndpoint. @@ -6407,8 +6545,10 @@ async def sample_deploy_index(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -6467,7 +6607,7 @@ async def undeploy_index( *, retry: OptionalRetry = gapic_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 an Index from IndexEndpoint. @@ -6508,8 +6648,10 @@ async def sample_undeploy_index(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -6571,7 +6713,7 @@ async def create_collection( collection_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 collection. @@ -6639,8 +6781,10 @@ async def sample_create_collection(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -6715,7 +6859,7 @@ async def delete_collection( name: Optional[str] = None, retry: OptionalRetry = gapic_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 collection. @@ -6763,8 +6907,10 @@ async def sample_delete_collection(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -6843,7 +6989,7 @@ async def get_collection( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Collection: r"""Gets a collection. @@ -6888,8 +7034,10 @@ async def sample_get_collection(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Collection: @@ -6952,7 +7100,7 @@ async def update_collection( 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]]] = (), ) -> warehouse.Collection: r"""Updates a collection. @@ -7012,8 +7160,10 @@ async def sample_update_collection(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Collection: @@ -7079,7 +7229,7 @@ async def list_collections( 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.ListCollectionsAsyncPager: r"""Lists collections inside a corpus. @@ -7123,8 +7273,10 @@ async def sample_list_collections(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.warehouse.pagers.ListCollectionsAsyncPager: @@ -7199,7 +7351,7 @@ async def add_collection_item( item: Optional[warehouse.CollectionItem] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.AddCollectionItemResponse: r"""Adds an item into a Collection. @@ -7246,8 +7398,10 @@ async def sample_add_collection_item(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.AddCollectionItemResponse: @@ -7310,7 +7464,7 @@ async def remove_collection_item( item: Optional[warehouse.CollectionItem] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.RemoveCollectionItemResponse: r"""Removes an item from a collection. @@ -7357,8 +7511,10 @@ async def sample_remove_collection_item(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.RemoveCollectionItemResponse: @@ -7421,7 +7577,7 @@ async def view_collection_items( collection: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ViewCollectionItemsAsyncPager: r"""View items inside a collection. @@ -7466,8 +7622,10 @@ async def sample_view_collection_items(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.warehouse.pagers.ViewCollectionItemsAsyncPager: @@ -7543,7 +7701,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. @@ -7554,8 +7712,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. @@ -7596,7 +7756,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. @@ -7607,8 +7767,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. @@ -7649,7 +7811,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. @@ -7665,8 +7827,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 """ @@ -7703,7 +7867,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. @@ -7718,8 +7882,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 """ diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/client.py index 45001703e78d..b16c5d797ff1 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/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.cloud.location import locations_pb2 # type: ignore @@ -781,6 +791,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( @@ -843,6 +857,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.visionai_v1.WarehouseClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "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.visionai.v1.Warehouse", + "credentialsType": None, + }, + ) + def create_asset( self, request: Optional[Union[warehouse.CreateAssetRequest, dict]] = None, @@ -852,7 +889,7 @@ def create_asset( asset_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]]] = (), ) -> warehouse.Asset: r"""Creates an asset inside corpus. @@ -915,8 +952,10 @@ def sample_create_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Asset: @@ -984,7 +1023,7 @@ def update_asset( 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]]] = (), ) -> warehouse.Asset: r"""Updates an asset inside corpus. @@ -1034,8 +1073,10 @@ def sample_update_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Asset: @@ -1102,7 +1143,7 @@ def get_asset( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Reads an asset inside corpus. @@ -1145,8 +1186,10 @@ def sample_get_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Asset: @@ -1209,7 +1252,7 @@ def list_assets( 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.ListAssetsPager: r"""Lists an list of assets inside corpus. @@ -1254,8 +1297,10 @@ def sample_list_assets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.warehouse.pagers.ListAssetsPager: @@ -1327,7 +1372,7 @@ def delete_asset( name: Optional[str] = None, retry: OptionalRetry = gapic_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 asset inside corpus. @@ -1374,8 +1419,10 @@ def sample_delete_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1450,7 +1497,7 @@ def upload_asset( *, retry: OptionalRetry = gapic_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"""Upload asset by specifing the asset Cloud Storage uri. For video warehouse, it requires users who call @@ -1502,8 +1549,10 @@ def sample_upload_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1558,7 +1607,7 @@ def generate_retrieval_url( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.GenerateRetrievalUrlResponse: r"""Generates a signed url for downloading the asset. For video warehouse, please see comment of UploadAsset @@ -1598,8 +1647,10 @@ def sample_generate_retrieval_url(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.GenerateRetrievalUrlResponse: @@ -1643,7 +1694,7 @@ def analyze_asset( *, retry: OptionalRetry = gapic_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"""Analyze asset to power search capability. @@ -1683,8 +1734,10 @@ def sample_analyze_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1739,7 +1792,7 @@ def index_asset( *, retry: OptionalRetry = gapic_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"""Index one asset for search. Supported corpus type: Corpus.Type.VIDEO_ON_DEMAND @@ -1780,8 +1833,10 @@ def sample_index_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1836,7 +1891,7 @@ def remove_index_asset( *, retry: OptionalRetry = gapic_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"""Remove one asset's index data for search. Supported corpus type: Corpus.Type.VIDEO_ON_DEMAND @@ -1877,8 +1932,10 @@ def sample_remove_index_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1934,7 +1991,7 @@ def view_indexed_assets( index: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ViewIndexedAssetsPager: r"""Lists assets inside an index. @@ -1980,8 +2037,10 @@ def sample_view_indexed_assets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.warehouse.pagers.ViewIndexedAssetsPager: @@ -2055,7 +2114,7 @@ def create_index( index_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 an Index under the corpus. @@ -2124,8 +2183,10 @@ def sample_create_index(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2199,7 +2260,7 @@ def update_index( 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 an Index under the corpus. Users can perform a metadata-only update or trigger a full index rebuild with @@ -2262,8 +2323,10 @@ def sample_update_index(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2336,7 +2399,7 @@ def get_index( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Index: r"""Gets the details of a single Index under a Corpus. @@ -2379,8 +2442,10 @@ def sample_get_index(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Index: @@ -2441,7 +2506,7 @@ def list_indexes( 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.ListIndexesPager: r"""List all Indexes in a given Corpus. @@ -2486,8 +2551,10 @@ def sample_list_indexes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.warehouse.pagers.ListIndexesPager: @@ -2559,7 +2626,7 @@ def delete_index( name: Optional[str] = None, retry: OptionalRetry = gapic_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 single Index. In order to delete an index, the caller must make sure that it is not deployed to any @@ -2608,8 +2675,10 @@ def sample_delete_index(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2686,7 +2755,7 @@ def create_corpus( corpus: Optional[warehouse.Corpus] = None, retry: OptionalRetry = gapic_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 corpus inside a project. @@ -2742,8 +2811,10 @@ def sample_create_corpus(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2814,7 +2885,7 @@ def get_corpus( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Corpus: r"""Gets corpus details inside a project. @@ -2857,8 +2928,10 @@ def sample_get_corpus(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Corpus: @@ -2919,7 +2992,7 @@ def update_corpus( 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]]] = (), ) -> warehouse.Corpus: r"""Updates a corpus in a project. @@ -2970,8 +3043,10 @@ def sample_update_corpus(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Corpus: @@ -3035,7 +3110,7 @@ def list_corpora( 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.ListCorporaPager: r"""Lists all corpora in a project. @@ -3079,8 +3154,10 @@ def sample_list_corpora(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.warehouse.pagers.ListCorporaPager: @@ -3152,7 +3229,7 @@ def delete_corpus( name: Optional[str] = None, retry: OptionalRetry = 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 corpus only if its empty. Returns empty response. @@ -3193,8 +3270,10 @@ def sample_delete_corpus(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -3242,7 +3321,7 @@ def analyze_corpus( *, retry: OptionalRetry = gapic_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"""Analyzes a corpus. @@ -3282,8 +3361,10 @@ def sample_analyze_corpus(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3340,7 +3421,7 @@ def create_data_schema( data_schema: Optional[warehouse.DataSchema] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Creates data schema inside corpus. @@ -3393,8 +3474,10 @@ def sample_create_data_schema(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.DataSchema: @@ -3456,7 +3539,7 @@ def update_data_schema( 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]]] = (), ) -> warehouse.DataSchema: r"""Updates data schema inside corpus. @@ -3508,8 +3591,10 @@ def sample_update_data_schema(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.DataSchema: @@ -3572,7 +3657,7 @@ def get_data_schema( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Gets data schema inside corpus. @@ -3616,8 +3701,10 @@ def sample_get_data_schema(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.DataSchema: @@ -3676,7 +3763,7 @@ def delete_data_schema( name: Optional[str] = None, retry: OptionalRetry = 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 data schema inside corpus. @@ -3716,8 +3803,10 @@ def sample_delete_data_schema(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -3766,7 +3855,7 @@ def list_data_schemas( 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.ListDataSchemasPager: r"""Lists a list of data schemas inside corpus. @@ -3811,8 +3900,10 @@ def sample_list_data_schemas(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.warehouse.pagers.ListDataSchemasPager: @@ -3886,7 +3977,7 @@ def create_annotation( annotation_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]]] = (), ) -> warehouse.Annotation: r"""Creates annotation inside asset. @@ -3948,8 +4039,10 @@ def sample_create_annotation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Annotation: @@ -4012,7 +4105,7 @@ def get_annotation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Reads annotation inside asset. @@ -4057,8 +4150,10 @@ def sample_get_annotation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Annotation: @@ -4117,7 +4212,7 @@ def list_annotations( 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.ListAnnotationsPager: r"""Lists a list of annotations inside asset. @@ -4162,8 +4257,10 @@ def sample_list_annotations(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.warehouse.pagers.ListAnnotationsPager: @@ -4236,7 +4333,7 @@ def update_annotation( 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]]] = (), ) -> warehouse.Annotation: r"""Updates annotation inside asset. @@ -4286,8 +4383,10 @@ def sample_update_annotation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Annotation: @@ -4350,7 +4449,7 @@ def delete_annotation( name: Optional[str] = None, retry: OptionalRetry = 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 annotation inside asset. @@ -4391,8 +4490,10 @@ def sample_delete_annotation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -4440,7 +4541,7 @@ def ingest_asset( *, retry: OptionalRetry = 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[warehouse.IngestAssetResponse]: r"""Ingests data for the asset. It is not allowed to ingest a data chunk which is already expired according @@ -4494,8 +4595,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.visionai_v1.types.IngestAssetResponse]: @@ -4526,7 +4629,7 @@ def clip_asset( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ClipAssetResponse: r"""Supported by STREAM_VIDEO corpus type. Generates clips for downloading. The api takes in a time range, and generates a clip @@ -4567,8 +4670,10 @@ def sample_clip_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.ClipAssetResponse: @@ -4610,7 +4715,7 @@ def generate_hls_uri( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.GenerateHlsUriResponse: r"""Generates a uri for an HLS manifest. The api takes in a collection of time ranges, and generates a URI for an @@ -4649,8 +4754,10 @@ def sample_generate_hls_uri(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.GenerateHlsUriResponse: @@ -4694,7 +4801,7 @@ def import_assets( *, retry: OptionalRetry = gapic_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 assets (images plus annotations) from a meta file on cloud storage. Each row in the meta file is @@ -4738,8 +4845,10 @@ def sample_import_assets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -4797,7 +4906,7 @@ def create_search_config( search_config_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]]] = (), ) -> warehouse.SearchConfig: r"""Creates a search configuration inside a corpus. @@ -4876,8 +4985,10 @@ def sample_create_search_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.visionai_v1.types.SearchConfig: @@ -4941,7 +5052,7 @@ def update_search_config( 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]]] = (), ) -> warehouse.SearchConfig: r"""Updates a search configuration inside a corpus. @@ -5009,8 +5120,10 @@ def sample_update_search_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.visionai_v1.types.SearchConfig: @@ -5073,7 +5186,7 @@ def get_search_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Gets a search configuration inside a corpus. @@ -5117,8 +5230,10 @@ def sample_get_search_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.visionai_v1.types.SearchConfig: @@ -5177,7 +5292,7 @@ def delete_search_config( name: Optional[str] = None, retry: OptionalRetry = 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 search configuration inside a corpus. @@ -5222,8 +5337,10 @@ def sample_delete_search_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -5272,7 +5389,7 @@ def list_search_configs( 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.ListSearchConfigsPager: r"""Lists all search configurations inside a corpus. @@ -5318,8 +5435,10 @@ def sample_list_search_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.visionai_v1.services.warehouse.pagers.ListSearchConfigsPager: @@ -5393,7 +5512,7 @@ def create_search_hypernym( search_hypernym_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]]] = (), ) -> warehouse.SearchHypernym: r"""Creates a SearchHypernym inside a corpus. @@ -5453,8 +5572,10 @@ def sample_create_search_hypernym(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.SearchHypernym: @@ -5520,7 +5641,7 @@ def update_search_hypernym( 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]]] = (), ) -> warehouse.SearchHypernym: r"""Updates a SearchHypernym inside a corpus. @@ -5573,8 +5694,10 @@ def sample_update_search_hypernym(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.SearchHypernym: @@ -5639,7 +5762,7 @@ def get_search_hypernym( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchHypernym: r"""Gets a SearchHypernym inside a corpus. @@ -5684,8 +5807,10 @@ def sample_get_search_hypernym(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.SearchHypernym: @@ -5746,7 +5871,7 @@ def delete_search_hypernym( name: Optional[str] = None, retry: OptionalRetry = 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 SearchHypernym inside a corpus. @@ -5788,8 +5913,10 @@ def sample_delete_search_hypernym(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -5838,7 +5965,7 @@ def list_search_hypernyms( 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.ListSearchHypernymsPager: r"""Lists SearchHypernyms inside a corpus. @@ -5884,8 +6011,10 @@ def sample_list_search_hypernyms(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.warehouse.pagers.ListSearchHypernymsPager: @@ -5956,7 +6085,7 @@ def search_assets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchAssetsPager: r"""Search media asset. @@ -5993,8 +6122,10 @@ def sample_search_assets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.warehouse.pagers.SearchAssetsPager: @@ -6052,7 +6183,7 @@ def search_index_endpoint( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchIndexEndpointPager: r"""Search a deployed index endpoint (IMAGE corpus type only). @@ -6095,8 +6226,10 @@ def sample_search_index_endpoint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.warehouse.pagers.SearchIndexEndpointPager: @@ -6159,7 +6292,7 @@ def create_index_endpoint( index_endpoint_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 an IndexEndpoint. @@ -6229,8 +6362,10 @@ def sample_create_index_endpoint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -6304,7 +6439,7 @@ def get_index_endpoint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.IndexEndpoint: r"""Gets an IndexEndpoint. @@ -6347,8 +6482,10 @@ def sample_get_index_endpoint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.IndexEndpoint: @@ -6406,7 +6543,7 @@ def list_index_endpoints( 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.ListIndexEndpointsPager: r"""Lists all IndexEndpoints in a project. @@ -6451,8 +6588,10 @@ def sample_list_index_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.visionai_v1.services.warehouse.pagers.ListIndexEndpointsPager: @@ -6525,7 +6664,7 @@ def update_index_endpoint( 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 an IndexEndpoint. @@ -6582,8 +6721,10 @@ def sample_update_index_endpoint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -6657,7 +6798,7 @@ def delete_index_endpoint( name: Optional[str] = None, retry: OptionalRetry = gapic_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 an IndexEndpoint. @@ -6703,8 +6844,10 @@ def sample_delete_index_endpoint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -6779,7 +6922,7 @@ def deploy_index( *, retry: OptionalRetry = gapic_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 an Index to IndexEndpoint. @@ -6823,8 +6966,10 @@ def sample_deploy_index(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -6881,7 +7026,7 @@ def undeploy_index( *, retry: OptionalRetry = gapic_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 an Index from IndexEndpoint. @@ -6922,8 +7067,10 @@ def sample_undeploy_index(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -6983,7 +7130,7 @@ def create_collection( collection_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 collection. @@ -7051,8 +7198,10 @@ def sample_create_collection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -7124,7 +7273,7 @@ def delete_collection( name: Optional[str] = None, retry: OptionalRetry = gapic_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 collection. @@ -7172,8 +7321,10 @@ def sample_delete_collection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -7249,7 +7400,7 @@ def get_collection( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Collection: r"""Gets a collection. @@ -7294,8 +7445,10 @@ def sample_get_collection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Collection: @@ -7355,7 +7508,7 @@ def update_collection( 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]]] = (), ) -> warehouse.Collection: r"""Updates a collection. @@ -7415,8 +7568,10 @@ def sample_update_collection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.Collection: @@ -7479,7 +7634,7 @@ def list_collections( 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.ListCollectionsPager: r"""Lists collections inside a corpus. @@ -7523,8 +7678,10 @@ def sample_list_collections(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.warehouse.pagers.ListCollectionsPager: @@ -7596,7 +7753,7 @@ def add_collection_item( item: Optional[warehouse.CollectionItem] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.AddCollectionItemResponse: r"""Adds an item into a Collection. @@ -7643,8 +7800,10 @@ def sample_add_collection_item(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.AddCollectionItemResponse: @@ -7704,7 +7863,7 @@ def remove_collection_item( item: Optional[warehouse.CollectionItem] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.RemoveCollectionItemResponse: r"""Removes an item from a collection. @@ -7751,8 +7910,10 @@ def sample_remove_collection_item(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.types.RemoveCollectionItemResponse: @@ -7812,7 +7973,7 @@ def view_collection_items( collection: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ViewCollectionItemsPager: r"""View items inside a collection. @@ -7857,8 +8018,10 @@ def sample_view_collection_items(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1.services.warehouse.pagers.ViewCollectionItemsPager: @@ -7944,7 +8107,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. @@ -7955,8 +8118,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. @@ -7997,7 +8162,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. @@ -8008,8 +8173,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. @@ -8050,7 +8217,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. @@ -8066,8 +8233,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 """ @@ -8104,7 +8273,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. @@ -8119,8 +8288,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 """ diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/pagers.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/pagers.py index 160445512781..85b0bd97b0ef 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/pagers.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/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 = warehouse.ListAssetsRequest(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 = warehouse.ListAssetsRequest(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 = warehouse.ViewIndexedAssetsRequest(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 = warehouse.ViewIndexedAssetsRequest(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 = warehouse.ListIndexesRequest(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 = warehouse.ListIndexesRequest(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 = warehouse.ListCorporaRequest(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 = warehouse.ListCorporaRequest(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 = warehouse.ListDataSchemasRequest(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 = warehouse.ListDataSchemasRequest(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 = warehouse.ListAnnotationsRequest(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 = warehouse.ListAnnotationsRequest(request) @@ -979,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. @@ -993,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 = warehouse.ListSearchConfigsRequest(request) @@ -1053,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. @@ -1067,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 = warehouse.ListSearchConfigsRequest(request) @@ -1131,7 +1159,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1145,8 +1173,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = warehouse.ListSearchHypernymsRequest(request) @@ -1205,7 +1235,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. @@ -1219,8 +1249,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 = warehouse.ListSearchHypernymsRequest(request) @@ -1283,7 +1315,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1297,8 +1329,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = warehouse.SearchAssetsRequest(request) @@ -1357,7 +1391,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. @@ -1371,8 +1405,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 = warehouse.SearchAssetsRequest(request) @@ -1435,7 +1471,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1449,8 +1485,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = warehouse.SearchIndexEndpointRequest(request) @@ -1509,7 +1547,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. @@ -1523,8 +1561,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 = warehouse.SearchIndexEndpointRequest(request) @@ -1587,7 +1627,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1601,8 +1641,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = warehouse.ListIndexEndpointsRequest(request) @@ -1661,7 +1703,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. @@ -1675,8 +1717,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 = warehouse.ListIndexEndpointsRequest(request) @@ -1739,7 +1783,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1753,8 +1797,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = warehouse.ListCollectionsRequest(request) @@ -1813,7 +1859,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. @@ -1827,8 +1873,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 = warehouse.ListCollectionsRequest(request) @@ -1891,7 +1939,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1905,8 +1953,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = warehouse.ViewCollectionItemsRequest(request) @@ -1965,7 +2015,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. @@ -1979,8 +2029,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 = warehouse.ViewCollectionItemsRequest(request) diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/transports/grpc.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/transports/grpc.py index 372e53e0beca..d553900dfba7 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/transports/grpc.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/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.visionai_v1.types import warehouse from .base import DEFAULT_CLIENT_INFO, WarehouseTransport +try: + from google.api_core import client_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.visionai.v1.Warehouse", + "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.visionai.v1.Warehouse", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WarehouseGrpcTransport(WarehouseTransport): """gRPC backend transport for Warehouse. @@ -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 create_asset(self) -> Callable[[warehouse.CreateAssetRequest], warehouse.Ass # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_asset" not in self._stubs: - self._stubs["create_asset"] = self.grpc_channel.unary_unary( + self._stubs["create_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateAsset", request_serializer=warehouse.CreateAssetRequest.serialize, response_deserializer=warehouse.Asset.deserialize, @@ -295,7 +383,7 @@ def update_asset(self) -> Callable[[warehouse.UpdateAssetRequest], warehouse.Ass # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_asset" not in self._stubs: - self._stubs["update_asset"] = self.grpc_channel.unary_unary( + self._stubs["update_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateAsset", request_serializer=warehouse.UpdateAssetRequest.serialize, response_deserializer=warehouse.Asset.deserialize, @@ -319,7 +407,7 @@ def get_asset(self) -> Callable[[warehouse.GetAssetRequest], warehouse.Asset]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_asset" not in self._stubs: - self._stubs["get_asset"] = self.grpc_channel.unary_unary( + self._stubs["get_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetAsset", request_serializer=warehouse.GetAssetRequest.serialize, response_deserializer=warehouse.Asset.deserialize, @@ -345,7 +433,7 @@ def list_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_assets" not in self._stubs: - self._stubs["list_assets"] = self.grpc_channel.unary_unary( + self._stubs["list_assets"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListAssets", request_serializer=warehouse.ListAssetsRequest.serialize, response_deserializer=warehouse.ListAssetsResponse.deserialize, @@ -371,7 +459,7 @@ def delete_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_asset" not in self._stubs: - self._stubs["delete_asset"] = self.grpc_channel.unary_unary( + self._stubs["delete_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteAsset", request_serializer=warehouse.DeleteAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -409,7 +497,7 @@ def upload_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "upload_asset" not in self._stubs: - self._stubs["upload_asset"] = self.grpc_channel.unary_unary( + self._stubs["upload_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UploadAsset", request_serializer=warehouse.UploadAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -440,7 +528,7 @@ def generate_retrieval_url( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_retrieval_url" not in self._stubs: - self._stubs["generate_retrieval_url"] = self.grpc_channel.unary_unary( + self._stubs["generate_retrieval_url"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GenerateRetrievalUrl", request_serializer=warehouse.GenerateRetrievalUrlRequest.serialize, response_deserializer=warehouse.GenerateRetrievalUrlResponse.deserialize, @@ -466,7 +554,7 @@ def analyze_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "analyze_asset" not in self._stubs: - self._stubs["analyze_asset"] = self.grpc_channel.unary_unary( + self._stubs["analyze_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/AnalyzeAsset", request_serializer=warehouse.AnalyzeAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -493,7 +581,7 @@ def index_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "index_asset" not in self._stubs: - self._stubs["index_asset"] = self.grpc_channel.unary_unary( + self._stubs["index_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/IndexAsset", request_serializer=warehouse.IndexAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -520,7 +608,7 @@ def remove_index_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_index_asset" not in self._stubs: - self._stubs["remove_index_asset"] = self.grpc_channel.unary_unary( + self._stubs["remove_index_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/RemoveIndexAsset", request_serializer=warehouse.RemoveIndexAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -548,7 +636,7 @@ def view_indexed_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "view_indexed_assets" not in self._stubs: - self._stubs["view_indexed_assets"] = self.grpc_channel.unary_unary( + self._stubs["view_indexed_assets"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ViewIndexedAssets", request_serializer=warehouse.ViewIndexedAssetsRequest.serialize, response_deserializer=warehouse.ViewIndexedAssetsResponse.deserialize, @@ -574,7 +662,7 @@ def create_index( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_index" not in self._stubs: - self._stubs["create_index"] = self.grpc_channel.unary_unary( + self._stubs["create_index"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateIndex", request_serializer=warehouse.CreateIndexRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -602,7 +690,7 @@ def update_index( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_index" not in self._stubs: - self._stubs["update_index"] = self.grpc_channel.unary_unary( + self._stubs["update_index"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateIndex", request_serializer=warehouse.UpdateIndexRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -626,7 +714,7 @@ def get_index(self) -> Callable[[warehouse.GetIndexRequest], warehouse.Index]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_index" not in self._stubs: - self._stubs["get_index"] = self.grpc_channel.unary_unary( + self._stubs["get_index"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetIndex", request_serializer=warehouse.GetIndexRequest.serialize, response_deserializer=warehouse.Index.deserialize, @@ -652,7 +740,7 @@ def list_indexes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_indexes" not in self._stubs: - self._stubs["list_indexes"] = self.grpc_channel.unary_unary( + self._stubs["list_indexes"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListIndexes", request_serializer=warehouse.ListIndexesRequest.serialize, response_deserializer=warehouse.ListIndexesResponse.deserialize, @@ -680,7 +768,7 @@ def delete_index( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_index" not in self._stubs: - self._stubs["delete_index"] = self.grpc_channel.unary_unary( + self._stubs["delete_index"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteIndex", request_serializer=warehouse.DeleteIndexRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -706,7 +794,7 @@ def create_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_corpus" not in self._stubs: - self._stubs["create_corpus"] = self.grpc_channel.unary_unary( + self._stubs["create_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateCorpus", request_serializer=warehouse.CreateCorpusRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -730,7 +818,7 @@ def get_corpus(self) -> Callable[[warehouse.GetCorpusRequest], warehouse.Corpus] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_corpus" not in self._stubs: - self._stubs["get_corpus"] = self.grpc_channel.unary_unary( + self._stubs["get_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetCorpus", request_serializer=warehouse.GetCorpusRequest.serialize, response_deserializer=warehouse.Corpus.deserialize, @@ -756,7 +844,7 @@ def update_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_corpus" not in self._stubs: - self._stubs["update_corpus"] = self.grpc_channel.unary_unary( + self._stubs["update_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateCorpus", request_serializer=warehouse.UpdateCorpusRequest.serialize, response_deserializer=warehouse.Corpus.deserialize, @@ -782,7 +870,7 @@ def list_corpora( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_corpora" not in self._stubs: - self._stubs["list_corpora"] = self.grpc_channel.unary_unary( + self._stubs["list_corpora"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListCorpora", request_serializer=warehouse.ListCorporaRequest.serialize, response_deserializer=warehouse.ListCorporaResponse.deserialize, @@ -809,7 +897,7 @@ def delete_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_corpus" not in self._stubs: - self._stubs["delete_corpus"] = self.grpc_channel.unary_unary( + self._stubs["delete_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteCorpus", request_serializer=warehouse.DeleteCorpusRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -835,7 +923,7 @@ def analyze_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "analyze_corpus" not in self._stubs: - self._stubs["analyze_corpus"] = self.grpc_channel.unary_unary( + self._stubs["analyze_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/AnalyzeCorpus", request_serializer=warehouse.AnalyzeCorpusRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -861,7 +949,7 @@ def create_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_data_schema" not in self._stubs: - self._stubs["create_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["create_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateDataSchema", request_serializer=warehouse.CreateDataSchemaRequest.serialize, response_deserializer=warehouse.DataSchema.deserialize, @@ -887,7 +975,7 @@ def update_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_data_schema" not in self._stubs: - self._stubs["update_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["update_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateDataSchema", request_serializer=warehouse.UpdateDataSchemaRequest.serialize, response_deserializer=warehouse.DataSchema.deserialize, @@ -913,7 +1001,7 @@ def get_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_schema" not in self._stubs: - self._stubs["get_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["get_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetDataSchema", request_serializer=warehouse.GetDataSchemaRequest.serialize, response_deserializer=warehouse.DataSchema.deserialize, @@ -939,7 +1027,7 @@ def delete_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_data_schema" not in self._stubs: - self._stubs["delete_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["delete_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteDataSchema", request_serializer=warehouse.DeleteDataSchemaRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -967,7 +1055,7 @@ def list_data_schemas( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_data_schemas" not in self._stubs: - self._stubs["list_data_schemas"] = self.grpc_channel.unary_unary( + self._stubs["list_data_schemas"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListDataSchemas", request_serializer=warehouse.ListDataSchemasRequest.serialize, response_deserializer=warehouse.ListDataSchemasResponse.deserialize, @@ -993,7 +1081,7 @@ def create_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_annotation" not in self._stubs: - self._stubs["create_annotation"] = self.grpc_channel.unary_unary( + self._stubs["create_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateAnnotation", request_serializer=warehouse.CreateAnnotationRequest.serialize, response_deserializer=warehouse.Annotation.deserialize, @@ -1019,7 +1107,7 @@ def get_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_annotation" not in self._stubs: - self._stubs["get_annotation"] = self.grpc_channel.unary_unary( + self._stubs["get_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetAnnotation", request_serializer=warehouse.GetAnnotationRequest.serialize, response_deserializer=warehouse.Annotation.deserialize, @@ -1047,7 +1135,7 @@ def list_annotations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_annotations" not in self._stubs: - self._stubs["list_annotations"] = self.grpc_channel.unary_unary( + self._stubs["list_annotations"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListAnnotations", request_serializer=warehouse.ListAnnotationsRequest.serialize, response_deserializer=warehouse.ListAnnotationsResponse.deserialize, @@ -1073,7 +1161,7 @@ def update_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_annotation" not in self._stubs: - self._stubs["update_annotation"] = self.grpc_channel.unary_unary( + self._stubs["update_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateAnnotation", request_serializer=warehouse.UpdateAnnotationRequest.serialize, response_deserializer=warehouse.Annotation.deserialize, @@ -1099,7 +1187,7 @@ def delete_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_annotation" not in self._stubs: - self._stubs["delete_annotation"] = self.grpc_channel.unary_unary( + self._stubs["delete_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteAnnotation", request_serializer=warehouse.DeleteAnnotationRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1129,7 +1217,7 @@ def ingest_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "ingest_asset" not in self._stubs: - self._stubs["ingest_asset"] = self.grpc_channel.stream_stream( + self._stubs["ingest_asset"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1.Warehouse/IngestAsset", request_serializer=warehouse.IngestAssetRequest.serialize, response_deserializer=warehouse.IngestAssetResponse.deserialize, @@ -1160,7 +1248,7 @@ def clip_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "clip_asset" not in self._stubs: - self._stubs["clip_asset"] = self.grpc_channel.unary_unary( + self._stubs["clip_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ClipAsset", request_serializer=warehouse.ClipAssetRequest.serialize, response_deserializer=warehouse.ClipAssetResponse.deserialize, @@ -1188,7 +1276,7 @@ def generate_hls_uri( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_hls_uri" not in self._stubs: - self._stubs["generate_hls_uri"] = self.grpc_channel.unary_unary( + self._stubs["generate_hls_uri"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GenerateHlsUri", request_serializer=warehouse.GenerateHlsUriRequest.serialize, response_deserializer=warehouse.GenerateHlsUriResponse.deserialize, @@ -1217,7 +1305,7 @@ def import_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_assets" not in self._stubs: - self._stubs["import_assets"] = self.grpc_channel.unary_unary( + self._stubs["import_assets"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ImportAssets", request_serializer=warehouse.ImportAssetsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1258,7 +1346,7 @@ def create_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_search_config" not in self._stubs: - self._stubs["create_search_config"] = self.grpc_channel.unary_unary( + self._stubs["create_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateSearchConfig", request_serializer=warehouse.CreateSearchConfigRequest.serialize, response_deserializer=warehouse.SearchConfig.deserialize, @@ -1298,7 +1386,7 @@ def update_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_search_config" not in self._stubs: - self._stubs["update_search_config"] = self.grpc_channel.unary_unary( + self._stubs["update_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateSearchConfig", request_serializer=warehouse.UpdateSearchConfigRequest.serialize, response_deserializer=warehouse.SearchConfig.deserialize, @@ -1324,7 +1412,7 @@ def get_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_search_config" not in self._stubs: - self._stubs["get_search_config"] = self.grpc_channel.unary_unary( + self._stubs["get_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetSearchConfig", request_serializer=warehouse.GetSearchConfigRequest.serialize, response_deserializer=warehouse.SearchConfig.deserialize, @@ -1353,7 +1441,7 @@ def delete_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_search_config" not in self._stubs: - self._stubs["delete_search_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteSearchConfig", request_serializer=warehouse.DeleteSearchConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1381,7 +1469,7 @@ def list_search_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_search_configs" not in self._stubs: - self._stubs["list_search_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_search_configs"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListSearchConfigs", request_serializer=warehouse.ListSearchConfigsRequest.serialize, response_deserializer=warehouse.ListSearchConfigsResponse.deserialize, @@ -1407,7 +1495,7 @@ def create_search_hypernym( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_search_hypernym" not in self._stubs: - self._stubs["create_search_hypernym"] = self.grpc_channel.unary_unary( + self._stubs["create_search_hypernym"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateSearchHypernym", request_serializer=warehouse.CreateSearchHypernymRequest.serialize, response_deserializer=warehouse.SearchHypernym.deserialize, @@ -1433,7 +1521,7 @@ def update_search_hypernym( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_search_hypernym" not in self._stubs: - self._stubs["update_search_hypernym"] = self.grpc_channel.unary_unary( + self._stubs["update_search_hypernym"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateSearchHypernym", request_serializer=warehouse.UpdateSearchHypernymRequest.serialize, response_deserializer=warehouse.SearchHypernym.deserialize, @@ -1459,7 +1547,7 @@ def get_search_hypernym( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_search_hypernym" not in self._stubs: - self._stubs["get_search_hypernym"] = self.grpc_channel.unary_unary( + self._stubs["get_search_hypernym"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetSearchHypernym", request_serializer=warehouse.GetSearchHypernymRequest.serialize, response_deserializer=warehouse.SearchHypernym.deserialize, @@ -1485,7 +1573,7 @@ def delete_search_hypernym( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_search_hypernym" not in self._stubs: - self._stubs["delete_search_hypernym"] = self.grpc_channel.unary_unary( + self._stubs["delete_search_hypernym"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteSearchHypernym", request_serializer=warehouse.DeleteSearchHypernymRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1513,7 +1601,7 @@ def list_search_hypernyms( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_search_hypernyms" not in self._stubs: - self._stubs["list_search_hypernyms"] = self.grpc_channel.unary_unary( + self._stubs["list_search_hypernyms"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListSearchHypernyms", request_serializer=warehouse.ListSearchHypernymsRequest.serialize, response_deserializer=warehouse.ListSearchHypernymsResponse.deserialize, @@ -1539,7 +1627,7 @@ def search_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_assets" not in self._stubs: - self._stubs["search_assets"] = self.grpc_channel.unary_unary( + self._stubs["search_assets"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/SearchAssets", request_serializer=warehouse.SearchAssetsRequest.serialize, response_deserializer=warehouse.SearchAssetsResponse.deserialize, @@ -1568,7 +1656,7 @@ def search_index_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_index_endpoint" not in self._stubs: - self._stubs["search_index_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["search_index_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/SearchIndexEndpoint", request_serializer=warehouse.SearchIndexEndpointRequest.serialize, response_deserializer=warehouse.SearchIndexEndpointResponse.deserialize, @@ -1594,7 +1682,7 @@ def create_index_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_index_endpoint" not in self._stubs: - self._stubs["create_index_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["create_index_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateIndexEndpoint", request_serializer=warehouse.CreateIndexEndpointRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1620,7 +1708,7 @@ def get_index_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_index_endpoint" not in self._stubs: - self._stubs["get_index_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["get_index_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetIndexEndpoint", request_serializer=warehouse.GetIndexEndpointRequest.serialize, response_deserializer=warehouse.IndexEndpoint.deserialize, @@ -1648,7 +1736,7 @@ def list_index_endpoints( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_index_endpoints" not in self._stubs: - self._stubs["list_index_endpoints"] = self.grpc_channel.unary_unary( + self._stubs["list_index_endpoints"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListIndexEndpoints", request_serializer=warehouse.ListIndexEndpointsRequest.serialize, response_deserializer=warehouse.ListIndexEndpointsResponse.deserialize, @@ -1674,7 +1762,7 @@ def update_index_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_index_endpoint" not in self._stubs: - self._stubs["update_index_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["update_index_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateIndexEndpoint", request_serializer=warehouse.UpdateIndexEndpointRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1700,7 +1788,7 @@ def delete_index_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_index_endpoint" not in self._stubs: - self._stubs["delete_index_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["delete_index_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteIndexEndpoint", request_serializer=warehouse.DeleteIndexEndpointRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1726,7 +1814,7 @@ def deploy_index( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "deploy_index" not in self._stubs: - self._stubs["deploy_index"] = self.grpc_channel.unary_unary( + self._stubs["deploy_index"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeployIndex", request_serializer=warehouse.DeployIndexRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1752,7 +1840,7 @@ def undeploy_index( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undeploy_index" not in self._stubs: - self._stubs["undeploy_index"] = self.grpc_channel.unary_unary( + self._stubs["undeploy_index"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UndeployIndex", request_serializer=warehouse.UndeployIndexRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1778,7 +1866,7 @@ def create_collection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_collection" not in self._stubs: - self._stubs["create_collection"] = self.grpc_channel.unary_unary( + self._stubs["create_collection"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateCollection", request_serializer=warehouse.CreateCollectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1804,7 +1892,7 @@ def delete_collection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_collection" not in self._stubs: - self._stubs["delete_collection"] = self.grpc_channel.unary_unary( + self._stubs["delete_collection"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteCollection", request_serializer=warehouse.DeleteCollectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1830,7 +1918,7 @@ def get_collection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_collection" not in self._stubs: - self._stubs["get_collection"] = self.grpc_channel.unary_unary( + self._stubs["get_collection"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetCollection", request_serializer=warehouse.GetCollectionRequest.serialize, response_deserializer=warehouse.Collection.deserialize, @@ -1856,7 +1944,7 @@ def update_collection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_collection" not in self._stubs: - self._stubs["update_collection"] = self.grpc_channel.unary_unary( + self._stubs["update_collection"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateCollection", request_serializer=warehouse.UpdateCollectionRequest.serialize, response_deserializer=warehouse.Collection.deserialize, @@ -1884,7 +1972,7 @@ def list_collections( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_collections" not in self._stubs: - self._stubs["list_collections"] = self.grpc_channel.unary_unary( + self._stubs["list_collections"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListCollections", request_serializer=warehouse.ListCollectionsRequest.serialize, response_deserializer=warehouse.ListCollectionsResponse.deserialize, @@ -1912,7 +2000,7 @@ def add_collection_item( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_collection_item" not in self._stubs: - self._stubs["add_collection_item"] = self.grpc_channel.unary_unary( + self._stubs["add_collection_item"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/AddCollectionItem", request_serializer=warehouse.AddCollectionItemRequest.serialize, response_deserializer=warehouse.AddCollectionItemResponse.deserialize, @@ -1940,7 +2028,7 @@ def remove_collection_item( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_collection_item" not in self._stubs: - self._stubs["remove_collection_item"] = self.grpc_channel.unary_unary( + self._stubs["remove_collection_item"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/RemoveCollectionItem", request_serializer=warehouse.RemoveCollectionItemRequest.serialize, response_deserializer=warehouse.RemoveCollectionItemResponse.deserialize, @@ -1968,7 +2056,7 @@ def view_collection_items( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "view_collection_items" not in self._stubs: - self._stubs["view_collection_items"] = self.grpc_channel.unary_unary( + self._stubs["view_collection_items"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ViewCollectionItems", request_serializer=warehouse.ViewCollectionItemsRequest.serialize, response_deserializer=warehouse.ViewCollectionItemsResponse.deserialize, @@ -1976,7 +2064,7 @@ def view_collection_items( return self._stubs["view_collection_items"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -1988,7 +2076,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, @@ -2005,7 +2093,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, @@ -2022,7 +2110,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, @@ -2041,7 +2129,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-visionai/google/cloud/visionai_v1/services/warehouse/transports/grpc_asyncio.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/transports/grpc_asyncio.py index a0098d4d36d8..c9850ed05d98 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/transports/grpc_asyncio.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/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.visionai_v1.types import warehouse from .base import DEFAULT_CLIENT_INFO, WarehouseTransport from .grpc import WarehouseGrpcTransport +try: + from google.api_core import client_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.visionai.v1.Warehouse", + "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.visionai.v1.Warehouse", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WarehouseGrpcAsyncIOTransport(WarehouseTransport): """gRPC AsyncIO backend transport for Warehouse. @@ -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 create_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_asset" not in self._stubs: - self._stubs["create_asset"] = self.grpc_channel.unary_unary( + self._stubs["create_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateAsset", request_serializer=warehouse.CreateAssetRequest.serialize, response_deserializer=warehouse.Asset.deserialize, @@ -309,7 +394,7 @@ def update_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_asset" not in self._stubs: - self._stubs["update_asset"] = self.grpc_channel.unary_unary( + self._stubs["update_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateAsset", request_serializer=warehouse.UpdateAssetRequest.serialize, response_deserializer=warehouse.Asset.deserialize, @@ -335,7 +420,7 @@ def get_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_asset" not in self._stubs: - self._stubs["get_asset"] = self.grpc_channel.unary_unary( + self._stubs["get_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetAsset", request_serializer=warehouse.GetAssetRequest.serialize, response_deserializer=warehouse.Asset.deserialize, @@ -363,7 +448,7 @@ def list_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_assets" not in self._stubs: - self._stubs["list_assets"] = self.grpc_channel.unary_unary( + self._stubs["list_assets"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListAssets", request_serializer=warehouse.ListAssetsRequest.serialize, response_deserializer=warehouse.ListAssetsResponse.deserialize, @@ -389,7 +474,7 @@ def delete_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_asset" not in self._stubs: - self._stubs["delete_asset"] = self.grpc_channel.unary_unary( + self._stubs["delete_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteAsset", request_serializer=warehouse.DeleteAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -427,7 +512,7 @@ def upload_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "upload_asset" not in self._stubs: - self._stubs["upload_asset"] = self.grpc_channel.unary_unary( + self._stubs["upload_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UploadAsset", request_serializer=warehouse.UploadAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -459,7 +544,7 @@ def generate_retrieval_url( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_retrieval_url" not in self._stubs: - self._stubs["generate_retrieval_url"] = self.grpc_channel.unary_unary( + self._stubs["generate_retrieval_url"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GenerateRetrievalUrl", request_serializer=warehouse.GenerateRetrievalUrlRequest.serialize, response_deserializer=warehouse.GenerateRetrievalUrlResponse.deserialize, @@ -485,7 +570,7 @@ def analyze_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "analyze_asset" not in self._stubs: - self._stubs["analyze_asset"] = self.grpc_channel.unary_unary( + self._stubs["analyze_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/AnalyzeAsset", request_serializer=warehouse.AnalyzeAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -512,7 +597,7 @@ def index_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "index_asset" not in self._stubs: - self._stubs["index_asset"] = self.grpc_channel.unary_unary( + self._stubs["index_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/IndexAsset", request_serializer=warehouse.IndexAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -541,7 +626,7 @@ def remove_index_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_index_asset" not in self._stubs: - self._stubs["remove_index_asset"] = self.grpc_channel.unary_unary( + self._stubs["remove_index_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/RemoveIndexAsset", request_serializer=warehouse.RemoveIndexAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -570,7 +655,7 @@ def view_indexed_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "view_indexed_assets" not in self._stubs: - self._stubs["view_indexed_assets"] = self.grpc_channel.unary_unary( + self._stubs["view_indexed_assets"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ViewIndexedAssets", request_serializer=warehouse.ViewIndexedAssetsRequest.serialize, response_deserializer=warehouse.ViewIndexedAssetsResponse.deserialize, @@ -596,7 +681,7 @@ def create_index( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_index" not in self._stubs: - self._stubs["create_index"] = self.grpc_channel.unary_unary( + self._stubs["create_index"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateIndex", request_serializer=warehouse.CreateIndexRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -624,7 +709,7 @@ def update_index( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_index" not in self._stubs: - self._stubs["update_index"] = self.grpc_channel.unary_unary( + self._stubs["update_index"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateIndex", request_serializer=warehouse.UpdateIndexRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -650,7 +735,7 @@ def get_index( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_index" not in self._stubs: - self._stubs["get_index"] = self.grpc_channel.unary_unary( + self._stubs["get_index"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetIndex", request_serializer=warehouse.GetIndexRequest.serialize, response_deserializer=warehouse.Index.deserialize, @@ -678,7 +763,7 @@ def list_indexes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_indexes" not in self._stubs: - self._stubs["list_indexes"] = self.grpc_channel.unary_unary( + self._stubs["list_indexes"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListIndexes", request_serializer=warehouse.ListIndexesRequest.serialize, response_deserializer=warehouse.ListIndexesResponse.deserialize, @@ -706,7 +791,7 @@ def delete_index( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_index" not in self._stubs: - self._stubs["delete_index"] = self.grpc_channel.unary_unary( + self._stubs["delete_index"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteIndex", request_serializer=warehouse.DeleteIndexRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -732,7 +817,7 @@ def create_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_corpus" not in self._stubs: - self._stubs["create_corpus"] = self.grpc_channel.unary_unary( + self._stubs["create_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateCorpus", request_serializer=warehouse.CreateCorpusRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -758,7 +843,7 @@ def get_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_corpus" not in self._stubs: - self._stubs["get_corpus"] = self.grpc_channel.unary_unary( + self._stubs["get_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetCorpus", request_serializer=warehouse.GetCorpusRequest.serialize, response_deserializer=warehouse.Corpus.deserialize, @@ -784,7 +869,7 @@ def update_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_corpus" not in self._stubs: - self._stubs["update_corpus"] = self.grpc_channel.unary_unary( + self._stubs["update_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateCorpus", request_serializer=warehouse.UpdateCorpusRequest.serialize, response_deserializer=warehouse.Corpus.deserialize, @@ -812,7 +897,7 @@ def list_corpora( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_corpora" not in self._stubs: - self._stubs["list_corpora"] = self.grpc_channel.unary_unary( + self._stubs["list_corpora"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListCorpora", request_serializer=warehouse.ListCorporaRequest.serialize, response_deserializer=warehouse.ListCorporaResponse.deserialize, @@ -839,7 +924,7 @@ def delete_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_corpus" not in self._stubs: - self._stubs["delete_corpus"] = self.grpc_channel.unary_unary( + self._stubs["delete_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteCorpus", request_serializer=warehouse.DeleteCorpusRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -867,7 +952,7 @@ def analyze_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "analyze_corpus" not in self._stubs: - self._stubs["analyze_corpus"] = self.grpc_channel.unary_unary( + self._stubs["analyze_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/AnalyzeCorpus", request_serializer=warehouse.AnalyzeCorpusRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -893,7 +978,7 @@ def create_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_data_schema" not in self._stubs: - self._stubs["create_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["create_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateDataSchema", request_serializer=warehouse.CreateDataSchemaRequest.serialize, response_deserializer=warehouse.DataSchema.deserialize, @@ -919,7 +1004,7 @@ def update_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_data_schema" not in self._stubs: - self._stubs["update_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["update_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateDataSchema", request_serializer=warehouse.UpdateDataSchemaRequest.serialize, response_deserializer=warehouse.DataSchema.deserialize, @@ -945,7 +1030,7 @@ def get_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_schema" not in self._stubs: - self._stubs["get_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["get_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetDataSchema", request_serializer=warehouse.GetDataSchemaRequest.serialize, response_deserializer=warehouse.DataSchema.deserialize, @@ -971,7 +1056,7 @@ def delete_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_data_schema" not in self._stubs: - self._stubs["delete_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["delete_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteDataSchema", request_serializer=warehouse.DeleteDataSchemaRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -999,7 +1084,7 @@ def list_data_schemas( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_data_schemas" not in self._stubs: - self._stubs["list_data_schemas"] = self.grpc_channel.unary_unary( + self._stubs["list_data_schemas"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListDataSchemas", request_serializer=warehouse.ListDataSchemasRequest.serialize, response_deserializer=warehouse.ListDataSchemasResponse.deserialize, @@ -1025,7 +1110,7 @@ def create_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_annotation" not in self._stubs: - self._stubs["create_annotation"] = self.grpc_channel.unary_unary( + self._stubs["create_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateAnnotation", request_serializer=warehouse.CreateAnnotationRequest.serialize, response_deserializer=warehouse.Annotation.deserialize, @@ -1051,7 +1136,7 @@ def get_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_annotation" not in self._stubs: - self._stubs["get_annotation"] = self.grpc_channel.unary_unary( + self._stubs["get_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetAnnotation", request_serializer=warehouse.GetAnnotationRequest.serialize, response_deserializer=warehouse.Annotation.deserialize, @@ -1079,7 +1164,7 @@ def list_annotations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_annotations" not in self._stubs: - self._stubs["list_annotations"] = self.grpc_channel.unary_unary( + self._stubs["list_annotations"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListAnnotations", request_serializer=warehouse.ListAnnotationsRequest.serialize, response_deserializer=warehouse.ListAnnotationsResponse.deserialize, @@ -1105,7 +1190,7 @@ def update_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_annotation" not in self._stubs: - self._stubs["update_annotation"] = self.grpc_channel.unary_unary( + self._stubs["update_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateAnnotation", request_serializer=warehouse.UpdateAnnotationRequest.serialize, response_deserializer=warehouse.Annotation.deserialize, @@ -1131,7 +1216,7 @@ def delete_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_annotation" not in self._stubs: - self._stubs["delete_annotation"] = self.grpc_channel.unary_unary( + self._stubs["delete_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteAnnotation", request_serializer=warehouse.DeleteAnnotationRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1163,7 +1248,7 @@ def ingest_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "ingest_asset" not in self._stubs: - self._stubs["ingest_asset"] = self.grpc_channel.stream_stream( + self._stubs["ingest_asset"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1.Warehouse/IngestAsset", request_serializer=warehouse.IngestAssetRequest.serialize, response_deserializer=warehouse.IngestAssetResponse.deserialize, @@ -1194,7 +1279,7 @@ def clip_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "clip_asset" not in self._stubs: - self._stubs["clip_asset"] = self.grpc_channel.unary_unary( + self._stubs["clip_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ClipAsset", request_serializer=warehouse.ClipAssetRequest.serialize, response_deserializer=warehouse.ClipAssetResponse.deserialize, @@ -1224,7 +1309,7 @@ def generate_hls_uri( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_hls_uri" not in self._stubs: - self._stubs["generate_hls_uri"] = self.grpc_channel.unary_unary( + self._stubs["generate_hls_uri"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GenerateHlsUri", request_serializer=warehouse.GenerateHlsUriRequest.serialize, response_deserializer=warehouse.GenerateHlsUriResponse.deserialize, @@ -1253,7 +1338,7 @@ def import_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_assets" not in self._stubs: - self._stubs["import_assets"] = self.grpc_channel.unary_unary( + self._stubs["import_assets"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ImportAssets", request_serializer=warehouse.ImportAssetsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1296,7 +1381,7 @@ def create_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_search_config" not in self._stubs: - self._stubs["create_search_config"] = self.grpc_channel.unary_unary( + self._stubs["create_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateSearchConfig", request_serializer=warehouse.CreateSearchConfigRequest.serialize, response_deserializer=warehouse.SearchConfig.deserialize, @@ -1338,7 +1423,7 @@ def update_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_search_config" not in self._stubs: - self._stubs["update_search_config"] = self.grpc_channel.unary_unary( + self._stubs["update_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateSearchConfig", request_serializer=warehouse.UpdateSearchConfigRequest.serialize, response_deserializer=warehouse.SearchConfig.deserialize, @@ -1366,7 +1451,7 @@ def get_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_search_config" not in self._stubs: - self._stubs["get_search_config"] = self.grpc_channel.unary_unary( + self._stubs["get_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetSearchConfig", request_serializer=warehouse.GetSearchConfigRequest.serialize, response_deserializer=warehouse.SearchConfig.deserialize, @@ -1395,7 +1480,7 @@ def delete_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_search_config" not in self._stubs: - self._stubs["delete_search_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteSearchConfig", request_serializer=warehouse.DeleteSearchConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1424,7 +1509,7 @@ def list_search_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_search_configs" not in self._stubs: - self._stubs["list_search_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_search_configs"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListSearchConfigs", request_serializer=warehouse.ListSearchConfigsRequest.serialize, response_deserializer=warehouse.ListSearchConfigsResponse.deserialize, @@ -1452,7 +1537,7 @@ def create_search_hypernym( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_search_hypernym" not in self._stubs: - self._stubs["create_search_hypernym"] = self.grpc_channel.unary_unary( + self._stubs["create_search_hypernym"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateSearchHypernym", request_serializer=warehouse.CreateSearchHypernymRequest.serialize, response_deserializer=warehouse.SearchHypernym.deserialize, @@ -1480,7 +1565,7 @@ def update_search_hypernym( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_search_hypernym" not in self._stubs: - self._stubs["update_search_hypernym"] = self.grpc_channel.unary_unary( + self._stubs["update_search_hypernym"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateSearchHypernym", request_serializer=warehouse.UpdateSearchHypernymRequest.serialize, response_deserializer=warehouse.SearchHypernym.deserialize, @@ -1508,7 +1593,7 @@ def get_search_hypernym( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_search_hypernym" not in self._stubs: - self._stubs["get_search_hypernym"] = self.grpc_channel.unary_unary( + self._stubs["get_search_hypernym"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetSearchHypernym", request_serializer=warehouse.GetSearchHypernymRequest.serialize, response_deserializer=warehouse.SearchHypernym.deserialize, @@ -1534,7 +1619,7 @@ def delete_search_hypernym( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_search_hypernym" not in self._stubs: - self._stubs["delete_search_hypernym"] = self.grpc_channel.unary_unary( + self._stubs["delete_search_hypernym"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteSearchHypernym", request_serializer=warehouse.DeleteSearchHypernymRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1563,7 +1648,7 @@ def list_search_hypernyms( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_search_hypernyms" not in self._stubs: - self._stubs["list_search_hypernyms"] = self.grpc_channel.unary_unary( + self._stubs["list_search_hypernyms"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListSearchHypernyms", request_serializer=warehouse.ListSearchHypernymsRequest.serialize, response_deserializer=warehouse.ListSearchHypernymsResponse.deserialize, @@ -1591,7 +1676,7 @@ def search_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_assets" not in self._stubs: - self._stubs["search_assets"] = self.grpc_channel.unary_unary( + self._stubs["search_assets"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/SearchAssets", request_serializer=warehouse.SearchAssetsRequest.serialize, response_deserializer=warehouse.SearchAssetsResponse.deserialize, @@ -1621,7 +1706,7 @@ def search_index_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_index_endpoint" not in self._stubs: - self._stubs["search_index_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["search_index_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/SearchIndexEndpoint", request_serializer=warehouse.SearchIndexEndpointRequest.serialize, response_deserializer=warehouse.SearchIndexEndpointResponse.deserialize, @@ -1649,7 +1734,7 @@ def create_index_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_index_endpoint" not in self._stubs: - self._stubs["create_index_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["create_index_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateIndexEndpoint", request_serializer=warehouse.CreateIndexEndpointRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1677,7 +1762,7 @@ def get_index_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_index_endpoint" not in self._stubs: - self._stubs["get_index_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["get_index_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetIndexEndpoint", request_serializer=warehouse.GetIndexEndpointRequest.serialize, response_deserializer=warehouse.IndexEndpoint.deserialize, @@ -1706,7 +1791,7 @@ def list_index_endpoints( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_index_endpoints" not in self._stubs: - self._stubs["list_index_endpoints"] = self.grpc_channel.unary_unary( + self._stubs["list_index_endpoints"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListIndexEndpoints", request_serializer=warehouse.ListIndexEndpointsRequest.serialize, response_deserializer=warehouse.ListIndexEndpointsResponse.deserialize, @@ -1734,7 +1819,7 @@ def update_index_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_index_endpoint" not in self._stubs: - self._stubs["update_index_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["update_index_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateIndexEndpoint", request_serializer=warehouse.UpdateIndexEndpointRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1762,7 +1847,7 @@ def delete_index_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_index_endpoint" not in self._stubs: - self._stubs["delete_index_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["delete_index_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteIndexEndpoint", request_serializer=warehouse.DeleteIndexEndpointRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1788,7 +1873,7 @@ def deploy_index( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "deploy_index" not in self._stubs: - self._stubs["deploy_index"] = self.grpc_channel.unary_unary( + self._stubs["deploy_index"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeployIndex", request_serializer=warehouse.DeployIndexRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1816,7 +1901,7 @@ def undeploy_index( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undeploy_index" not in self._stubs: - self._stubs["undeploy_index"] = self.grpc_channel.unary_unary( + self._stubs["undeploy_index"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UndeployIndex", request_serializer=warehouse.UndeployIndexRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1844,7 +1929,7 @@ def create_collection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_collection" not in self._stubs: - self._stubs["create_collection"] = self.grpc_channel.unary_unary( + self._stubs["create_collection"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateCollection", request_serializer=warehouse.CreateCollectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1872,7 +1957,7 @@ def delete_collection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_collection" not in self._stubs: - self._stubs["delete_collection"] = self.grpc_channel.unary_unary( + self._stubs["delete_collection"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteCollection", request_serializer=warehouse.DeleteCollectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1898,7 +1983,7 @@ def get_collection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_collection" not in self._stubs: - self._stubs["get_collection"] = self.grpc_channel.unary_unary( + self._stubs["get_collection"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetCollection", request_serializer=warehouse.GetCollectionRequest.serialize, response_deserializer=warehouse.Collection.deserialize, @@ -1924,7 +2009,7 @@ def update_collection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_collection" not in self._stubs: - self._stubs["update_collection"] = self.grpc_channel.unary_unary( + self._stubs["update_collection"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateCollection", request_serializer=warehouse.UpdateCollectionRequest.serialize, response_deserializer=warehouse.Collection.deserialize, @@ -1952,7 +2037,7 @@ def list_collections( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_collections" not in self._stubs: - self._stubs["list_collections"] = self.grpc_channel.unary_unary( + self._stubs["list_collections"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListCollections", request_serializer=warehouse.ListCollectionsRequest.serialize, response_deserializer=warehouse.ListCollectionsResponse.deserialize, @@ -1981,7 +2066,7 @@ def add_collection_item( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_collection_item" not in self._stubs: - self._stubs["add_collection_item"] = self.grpc_channel.unary_unary( + self._stubs["add_collection_item"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/AddCollectionItem", request_serializer=warehouse.AddCollectionItemRequest.serialize, response_deserializer=warehouse.AddCollectionItemResponse.deserialize, @@ -2010,7 +2095,7 @@ def remove_collection_item( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_collection_item" not in self._stubs: - self._stubs["remove_collection_item"] = self.grpc_channel.unary_unary( + self._stubs["remove_collection_item"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/RemoveCollectionItem", request_serializer=warehouse.RemoveCollectionItemRequest.serialize, response_deserializer=warehouse.RemoveCollectionItemResponse.deserialize, @@ -2039,7 +2124,7 @@ def view_collection_items( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "view_collection_items" not in self._stubs: - self._stubs["view_collection_items"] = self.grpc_channel.unary_unary( + self._stubs["view_collection_items"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ViewCollectionItems", request_serializer=warehouse.ViewCollectionItemsRequest.serialize, response_deserializer=warehouse.ViewCollectionItemsResponse.deserialize, @@ -2437,7 +2522,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: @@ -2453,7 +2538,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, @@ -2470,7 +2555,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, @@ -2487,7 +2572,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, @@ -2506,7 +2591,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-visionai/google/cloud/visionai_v1/services/warehouse/transports/rest.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/transports/rest.py index f2bb45f69c8e..845f3c188a16 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/transports/rest.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/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, @@ -550,8 +558,10 @@ def post_view_indexed_assets(self, response): def pre_add_collection_item( self, request: warehouse.AddCollectionItemRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.AddCollectionItemRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.AddCollectionItemRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for add_collection_item Override in a subclass to manipulate the request or metadata @@ -573,8 +583,8 @@ def post_add_collection_item( def pre_analyze_asset( self, request: warehouse.AnalyzeAssetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.AnalyzeAssetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.AnalyzeAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for analyze_asset Override in a subclass to manipulate the request or metadata @@ -596,8 +606,8 @@ def post_analyze_asset( def pre_analyze_corpus( self, request: warehouse.AnalyzeCorpusRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.AnalyzeCorpusRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.AnalyzeCorpusRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for analyze_corpus Override in a subclass to manipulate the request or metadata @@ -617,8 +627,10 @@ def post_analyze_corpus( return response def pre_clip_asset( - self, request: warehouse.ClipAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.ClipAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.ClipAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.ClipAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for clip_asset Override in a subclass to manipulate the request or metadata @@ -640,8 +652,10 @@ def post_clip_asset( def pre_create_annotation( self, request: warehouse.CreateAnnotationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.CreateAnnotationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.CreateAnnotationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_annotation Override in a subclass to manipulate the request or metadata @@ -661,8 +675,10 @@ def post_create_annotation( return response def pre_create_asset( - self, request: warehouse.CreateAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.CreateAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.CreateAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.CreateAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_asset Override in a subclass to manipulate the request or metadata @@ -682,8 +698,10 @@ def post_create_asset(self, response: warehouse.Asset) -> warehouse.Asset: def pre_create_collection( self, request: warehouse.CreateCollectionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.CreateCollectionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.CreateCollectionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_collection Override in a subclass to manipulate the request or metadata @@ -705,8 +723,8 @@ def post_create_collection( def pre_create_corpus( self, request: warehouse.CreateCorpusRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.CreateCorpusRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.CreateCorpusRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_corpus Override in a subclass to manipulate the request or metadata @@ -728,8 +746,10 @@ def post_create_corpus( def pre_create_data_schema( self, request: warehouse.CreateDataSchemaRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.CreateDataSchemaRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.CreateDataSchemaRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_data_schema Override in a subclass to manipulate the request or metadata @@ -749,8 +769,10 @@ def post_create_data_schema( return response def pre_create_index( - self, request: warehouse.CreateIndexRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.CreateIndexRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.CreateIndexRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.CreateIndexRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_index Override in a subclass to manipulate the request or metadata @@ -772,8 +794,10 @@ def post_create_index( def pre_create_index_endpoint( self, request: warehouse.CreateIndexEndpointRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.CreateIndexEndpointRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.CreateIndexEndpointRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_index_endpoint Override in a subclass to manipulate the request or metadata @@ -795,8 +819,10 @@ def post_create_index_endpoint( def pre_create_search_config( self, request: warehouse.CreateSearchConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.CreateSearchConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.CreateSearchConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_search_config Override in a subclass to manipulate the request or metadata @@ -818,8 +844,10 @@ def post_create_search_config( def pre_create_search_hypernym( self, request: warehouse.CreateSearchHypernymRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.CreateSearchHypernymRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.CreateSearchHypernymRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_search_hypernym Override in a subclass to manipulate the request or metadata @@ -841,8 +869,10 @@ def post_create_search_hypernym( def pre_delete_annotation( self, request: warehouse.DeleteAnnotationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.DeleteAnnotationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.DeleteAnnotationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_annotation Override in a subclass to manipulate the request or metadata @@ -851,8 +881,10 @@ def pre_delete_annotation( return request, metadata def pre_delete_asset( - self, request: warehouse.DeleteAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.DeleteAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.DeleteAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.DeleteAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_asset Override in a subclass to manipulate the request or metadata @@ -874,8 +906,10 @@ def post_delete_asset( def pre_delete_collection( self, request: warehouse.DeleteCollectionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.DeleteCollectionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.DeleteCollectionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_collection Override in a subclass to manipulate the request or metadata @@ -897,8 +931,8 @@ def post_delete_collection( def pre_delete_corpus( self, request: warehouse.DeleteCorpusRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.DeleteCorpusRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.DeleteCorpusRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_corpus Override in a subclass to manipulate the request or metadata @@ -909,8 +943,10 @@ def pre_delete_corpus( def pre_delete_data_schema( self, request: warehouse.DeleteDataSchemaRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.DeleteDataSchemaRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.DeleteDataSchemaRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_data_schema Override in a subclass to manipulate the request or metadata @@ -919,8 +955,10 @@ def pre_delete_data_schema( return request, metadata def pre_delete_index( - self, request: warehouse.DeleteIndexRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.DeleteIndexRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.DeleteIndexRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.DeleteIndexRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_index Override in a subclass to manipulate the request or metadata @@ -942,8 +980,10 @@ def post_delete_index( def pre_delete_index_endpoint( self, request: warehouse.DeleteIndexEndpointRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.DeleteIndexEndpointRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.DeleteIndexEndpointRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_index_endpoint Override in a subclass to manipulate the request or metadata @@ -965,8 +1005,10 @@ def post_delete_index_endpoint( def pre_delete_search_config( self, request: warehouse.DeleteSearchConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.DeleteSearchConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.DeleteSearchConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_search_config Override in a subclass to manipulate the request or metadata @@ -977,8 +1019,10 @@ def pre_delete_search_config( def pre_delete_search_hypernym( self, request: warehouse.DeleteSearchHypernymRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.DeleteSearchHypernymRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.DeleteSearchHypernymRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_search_hypernym Override in a subclass to manipulate the request or metadata @@ -987,8 +1031,10 @@ def pre_delete_search_hypernym( return request, metadata def pre_deploy_index( - self, request: warehouse.DeployIndexRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.DeployIndexRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.DeployIndexRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.DeployIndexRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for deploy_index Override in a subclass to manipulate the request or metadata @@ -1010,8 +1056,10 @@ def post_deploy_index( def pre_generate_hls_uri( self, request: warehouse.GenerateHlsUriRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.GenerateHlsUriRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.GenerateHlsUriRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for generate_hls_uri Override in a subclass to manipulate the request or metadata @@ -1033,8 +1081,10 @@ def post_generate_hls_uri( def pre_generate_retrieval_url( self, request: warehouse.GenerateRetrievalUrlRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.GenerateRetrievalUrlRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.GenerateRetrievalUrlRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for generate_retrieval_url Override in a subclass to manipulate the request or metadata @@ -1056,8 +1106,8 @@ def post_generate_retrieval_url( def pre_get_annotation( self, request: warehouse.GetAnnotationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.GetAnnotationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.GetAnnotationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_annotation Override in a subclass to manipulate the request or metadata @@ -1077,8 +1127,10 @@ def post_get_annotation( return response def pre_get_asset( - self, request: warehouse.GetAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.GetAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.GetAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.GetAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_asset Override in a subclass to manipulate the request or metadata @@ -1098,8 +1150,8 @@ def post_get_asset(self, response: warehouse.Asset) -> warehouse.Asset: def pre_get_collection( self, request: warehouse.GetCollectionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.GetCollectionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.GetCollectionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_collection Override in a subclass to manipulate the request or metadata @@ -1119,8 +1171,10 @@ def post_get_collection( return response def pre_get_corpus( - self, request: warehouse.GetCorpusRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.GetCorpusRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.GetCorpusRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.GetCorpusRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_corpus Override in a subclass to manipulate the request or metadata @@ -1140,8 +1194,8 @@ def post_get_corpus(self, response: warehouse.Corpus) -> warehouse.Corpus: def pre_get_data_schema( self, request: warehouse.GetDataSchemaRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.GetDataSchemaRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.GetDataSchemaRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_data_schema Override in a subclass to manipulate the request or metadata @@ -1161,8 +1215,10 @@ def post_get_data_schema( return response def pre_get_index( - self, request: warehouse.GetIndexRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.GetIndexRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.GetIndexRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.GetIndexRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_index Override in a subclass to manipulate the request or metadata @@ -1182,8 +1238,10 @@ def post_get_index(self, response: warehouse.Index) -> warehouse.Index: def pre_get_index_endpoint( self, request: warehouse.GetIndexEndpointRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.GetIndexEndpointRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.GetIndexEndpointRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_index_endpoint Override in a subclass to manipulate the request or metadata @@ -1205,8 +1263,10 @@ def post_get_index_endpoint( def pre_get_search_config( self, request: warehouse.GetSearchConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.GetSearchConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.GetSearchConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_search_config Override in a subclass to manipulate the request or metadata @@ -1228,8 +1288,10 @@ def post_get_search_config( def pre_get_search_hypernym( self, request: warehouse.GetSearchHypernymRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.GetSearchHypernymRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.GetSearchHypernymRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_search_hypernym Override in a subclass to manipulate the request or metadata @@ -1251,8 +1313,8 @@ def post_get_search_hypernym( def pre_import_assets( self, request: warehouse.ImportAssetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.ImportAssetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.ImportAssetsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for import_assets Override in a subclass to manipulate the request or metadata @@ -1272,8 +1334,10 @@ def post_import_assets( return response def pre_index_asset( - self, request: warehouse.IndexAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.IndexAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.IndexAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.IndexAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for index_asset Override in a subclass to manipulate the request or metadata @@ -1295,8 +1359,10 @@ def post_index_asset( def pre_list_annotations( self, request: warehouse.ListAnnotationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.ListAnnotationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.ListAnnotationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_annotations Override in a subclass to manipulate the request or metadata @@ -1316,8 +1382,10 @@ def post_list_annotations( return response def pre_list_assets( - self, request: warehouse.ListAssetsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.ListAssetsRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.ListAssetsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.ListAssetsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_assets Override in a subclass to manipulate the request or metadata @@ -1339,8 +1407,10 @@ def post_list_assets( def pre_list_collections( self, request: warehouse.ListCollectionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.ListCollectionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.ListCollectionsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_collections Override in a subclass to manipulate the request or metadata @@ -1360,8 +1430,10 @@ def post_list_collections( return response def pre_list_corpora( - self, request: warehouse.ListCorporaRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.ListCorporaRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.ListCorporaRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.ListCorporaRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_corpora Override in a subclass to manipulate the request or metadata @@ -1383,8 +1455,10 @@ def post_list_corpora( def pre_list_data_schemas( self, request: warehouse.ListDataSchemasRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.ListDataSchemasRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.ListDataSchemasRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_data_schemas Override in a subclass to manipulate the request or metadata @@ -1406,8 +1480,10 @@ def post_list_data_schemas( def pre_list_index_endpoints( self, request: warehouse.ListIndexEndpointsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.ListIndexEndpointsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.ListIndexEndpointsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_index_endpoints Override in a subclass to manipulate the request or metadata @@ -1427,8 +1503,10 @@ def post_list_index_endpoints( return response def pre_list_indexes( - self, request: warehouse.ListIndexesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.ListIndexesRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.ListIndexesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.ListIndexesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_indexes Override in a subclass to manipulate the request or metadata @@ -1450,8 +1528,10 @@ def post_list_indexes( def pre_list_search_configs( self, request: warehouse.ListSearchConfigsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.ListSearchConfigsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.ListSearchConfigsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_search_configs Override in a subclass to manipulate the request or metadata @@ -1473,8 +1553,10 @@ def post_list_search_configs( def pre_list_search_hypernyms( self, request: warehouse.ListSearchHypernymsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.ListSearchHypernymsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.ListSearchHypernymsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_search_hypernyms Override in a subclass to manipulate the request or metadata @@ -1496,8 +1578,10 @@ def post_list_search_hypernyms( def pre_remove_collection_item( self, request: warehouse.RemoveCollectionItemRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.RemoveCollectionItemRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.RemoveCollectionItemRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for remove_collection_item Override in a subclass to manipulate the request or metadata @@ -1519,8 +1603,10 @@ def post_remove_collection_item( def pre_remove_index_asset( self, request: warehouse.RemoveIndexAssetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.RemoveIndexAssetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.RemoveIndexAssetRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for remove_index_asset Override in a subclass to manipulate the request or metadata @@ -1542,8 +1628,8 @@ def post_remove_index_asset( def pre_search_assets( self, request: warehouse.SearchAssetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.SearchAssetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.SearchAssetsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search_assets Override in a subclass to manipulate the request or metadata @@ -1565,8 +1651,10 @@ def post_search_assets( def pre_search_index_endpoint( self, request: warehouse.SearchIndexEndpointRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.SearchIndexEndpointRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.SearchIndexEndpointRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for search_index_endpoint Override in a subclass to manipulate the request or metadata @@ -1588,8 +1676,8 @@ def post_search_index_endpoint( def pre_undeploy_index( self, request: warehouse.UndeployIndexRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.UndeployIndexRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.UndeployIndexRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for undeploy_index Override in a subclass to manipulate the request or metadata @@ -1611,8 +1699,10 @@ def post_undeploy_index( def pre_update_annotation( self, request: warehouse.UpdateAnnotationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.UpdateAnnotationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.UpdateAnnotationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_annotation Override in a subclass to manipulate the request or metadata @@ -1632,8 +1722,10 @@ def post_update_annotation( return response def pre_update_asset( - self, request: warehouse.UpdateAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.UpdateAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.UpdateAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.UpdateAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_asset Override in a subclass to manipulate the request or metadata @@ -1653,8 +1745,10 @@ def post_update_asset(self, response: warehouse.Asset) -> warehouse.Asset: def pre_update_collection( self, request: warehouse.UpdateCollectionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.UpdateCollectionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.UpdateCollectionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_collection Override in a subclass to manipulate the request or metadata @@ -1676,8 +1770,8 @@ def post_update_collection( def pre_update_corpus( self, request: warehouse.UpdateCorpusRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.UpdateCorpusRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.UpdateCorpusRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_corpus Override in a subclass to manipulate the request or metadata @@ -1697,8 +1791,10 @@ def post_update_corpus(self, response: warehouse.Corpus) -> warehouse.Corpus: def pre_update_data_schema( self, request: warehouse.UpdateDataSchemaRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.UpdateDataSchemaRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.UpdateDataSchemaRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_data_schema Override in a subclass to manipulate the request or metadata @@ -1718,8 +1814,10 @@ def post_update_data_schema( return response def pre_update_index( - self, request: warehouse.UpdateIndexRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.UpdateIndexRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.UpdateIndexRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.UpdateIndexRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_index Override in a subclass to manipulate the request or metadata @@ -1741,8 +1839,10 @@ def post_update_index( def pre_update_index_endpoint( self, request: warehouse.UpdateIndexEndpointRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.UpdateIndexEndpointRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.UpdateIndexEndpointRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_index_endpoint Override in a subclass to manipulate the request or metadata @@ -1764,8 +1864,10 @@ def post_update_index_endpoint( def pre_update_search_config( self, request: warehouse.UpdateSearchConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.UpdateSearchConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.UpdateSearchConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_search_config Override in a subclass to manipulate the request or metadata @@ -1787,8 +1889,10 @@ def post_update_search_config( def pre_update_search_hypernym( self, request: warehouse.UpdateSearchHypernymRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.UpdateSearchHypernymRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.UpdateSearchHypernymRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_search_hypernym Override in a subclass to manipulate the request or metadata @@ -1808,8 +1912,10 @@ def post_update_search_hypernym( return response def pre_upload_asset( - self, request: warehouse.UploadAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.UploadAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.UploadAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.UploadAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for upload_asset Override in a subclass to manipulate the request or metadata @@ -1831,8 +1937,10 @@ def post_upload_asset( def pre_view_collection_items( self, request: warehouse.ViewCollectionItemsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.ViewCollectionItemsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.ViewCollectionItemsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for view_collection_items Override in a subclass to manipulate the request or metadata @@ -1854,8 +1962,10 @@ def post_view_collection_items( def pre_view_indexed_assets( self, request: warehouse.ViewIndexedAssetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.ViewIndexedAssetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.ViewIndexedAssetsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for view_indexed_assets Override in a subclass to manipulate the request or metadata @@ -1877,8 +1987,10 @@ def post_view_indexed_assets( 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 @@ -1898,8 +2010,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 @@ -1919,8 +2033,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 @@ -1942,8 +2058,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 @@ -2166,7 +2284,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.AddCollectionItemResponse: r"""Call the add collection item method over HTTP. @@ -2177,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: ~.warehouse.AddCollectionItemResponse: @@ -2190,6 +2310,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseAddCollectionItem._get_http_options() ) + request, metadata = self._interceptor.pre_add_collection_item( request, metadata ) @@ -2206,6 +2327,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.AddCollectionItem", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "AddCollectionItem", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._AddCollectionItem._get_response( self._host, @@ -2227,7 +2375,31 @@ def __call__( pb_resp = warehouse.AddCollectionItemResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_collection_item(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.AddCollectionItemResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.add_collection_item", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "AddCollectionItem", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AnalyzeAsset( @@ -2265,7 +2437,7 @@ 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 analyze asset method over HTTP. @@ -2275,8 +2447,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2289,6 +2463,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseAnalyzeAsset._get_http_options() ) + request, metadata = self._interceptor.pre_analyze_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseAnalyzeAsset._get_transcoded_request( @@ -2307,6 +2482,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.AnalyzeAsset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "AnalyzeAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._AnalyzeAsset._get_response( self._host, @@ -2326,7 +2528,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_analyze_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.analyze_asset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "AnalyzeAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AnalyzeCorpus( @@ -2364,7 +2588,7 @@ 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 analyze corpus method over HTTP. @@ -2374,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: ~.operations_pb2.Operation: @@ -2388,6 +2614,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseAnalyzeCorpus._get_http_options() ) + request, metadata = self._interceptor.pre_analyze_corpus(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseAnalyzeCorpus._get_transcoded_request( @@ -2408,6 +2635,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.AnalyzeCorpus", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "AnalyzeCorpus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._AnalyzeCorpus._get_response( self._host, @@ -2427,7 +2681,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_analyze_corpus(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.analyze_corpus", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "AnalyzeCorpus", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ClipAsset(_BaseWarehouseRestTransport._BaseClipAsset, WarehouseRestStub): @@ -2463,7 +2739,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ClipAssetResponse: r"""Call the clip asset method over HTTP. @@ -2473,8 +2749,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.ClipAssetResponse: @@ -2484,6 +2762,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseClipAsset._get_http_options() ) + request, metadata = self._interceptor.pre_clip_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseClipAsset._get_transcoded_request( @@ -2502,6 +2781,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.ClipAsset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ClipAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ClipAsset._get_response( self._host, @@ -2523,7 +2829,29 @@ def __call__( pb_resp = warehouse.ClipAssetResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_clip_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ClipAssetResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.clip_asset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ClipAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateAnnotation( @@ -2561,7 +2889,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Call the create annotation method over HTTP. @@ -2571,8 +2899,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.Annotation: @@ -2585,6 +2915,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateAnnotation._get_http_options() ) + request, metadata = self._interceptor.pre_create_annotation( request, metadata ) @@ -2601,6 +2932,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.CreateAnnotation", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateAnnotation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateAnnotation._get_response( self._host, @@ -2622,7 +2980,29 @@ def __call__( pb_resp = warehouse.Annotation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_annotation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Annotation.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.create_annotation", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateAnnotation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateAsset(_BaseWarehouseRestTransport._BaseCreateAsset, WarehouseRestStub): @@ -2658,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]]] = (), ) -> warehouse.Asset: r"""Call the create asset method over HTTP. @@ -2669,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: ~.warehouse.Asset: @@ -2687,6 +3069,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateAsset._get_http_options() ) + request, metadata = self._interceptor.pre_create_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseCreateAsset._get_transcoded_request( @@ -2705,6 +3088,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.CreateAsset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateAsset._get_response( self._host, @@ -2726,7 +3136,29 @@ def __call__( pb_resp = warehouse.Asset.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Asset.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.create_asset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCollection( @@ -2764,7 +3196,7 @@ 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 collection method over HTTP. @@ -2774,8 +3206,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2788,6 +3222,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateCollection._get_http_options() ) + request, metadata = self._interceptor.pre_create_collection( request, metadata ) @@ -2804,6 +3239,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.CreateCollection", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateCollection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateCollection._get_response( self._host, @@ -2823,7 +3285,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_collection(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.create_collection", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateCollection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCorpus( @@ -2861,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 create corpus method over HTTP. @@ -2871,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: @@ -2885,6 +3371,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateCorpus._get_http_options() ) + request, metadata = self._interceptor.pre_create_corpus(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseCreateCorpus._get_transcoded_request( @@ -2903,6 +3390,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.CreateCorpus", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateCorpus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateCorpus._get_response( self._host, @@ -2922,7 +3436,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_corpus(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.create_corpus", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateCorpus", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateDataSchema( @@ -2960,7 +3496,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Call the create data schema method over HTTP. @@ -2970,8 +3506,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.DataSchema: @@ -2984,6 +3522,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateDataSchema._get_http_options() ) + request, metadata = self._interceptor.pre_create_data_schema( request, metadata ) @@ -3000,6 +3539,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.CreateDataSchema", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateDataSchema", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateDataSchema._get_response( self._host, @@ -3021,7 +3587,29 @@ def __call__( pb_resp = warehouse.DataSchema.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_data_schema(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.DataSchema.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.create_data_schema", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateDataSchema", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateIndex(_BaseWarehouseRestTransport._BaseCreateIndex, WarehouseRestStub): @@ -3057,7 +3645,7 @@ 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 index method over HTTP. @@ -3067,8 +3655,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3081,6 +3671,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateIndex._get_http_options() ) + request, metadata = self._interceptor.pre_create_index(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseCreateIndex._get_transcoded_request( @@ -3099,6 +3690,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.CreateIndex", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateIndex", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateIndex._get_response( self._host, @@ -3118,7 +3736,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_index(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.create_index", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateIndex", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateIndexEndpoint( @@ -3156,7 +3796,7 @@ 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 index endpoint method over HTTP. @@ -3167,8 +3807,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3181,6 +3823,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateIndexEndpoint._get_http_options() ) + request, metadata = self._interceptor.pre_create_index_endpoint( request, metadata ) @@ -3197,6 +3840,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.CreateIndexEndpoint", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateIndexEndpoint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateIndexEndpoint._get_response( self._host, @@ -3216,7 +3886,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_index_endpoint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.create_index_endpoint", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateIndexEndpoint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSearchConfig( @@ -3254,7 +3946,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Call the create search config method over HTTP. @@ -3265,8 +3957,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.SearchConfig: @@ -3279,6 +3973,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateSearchConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_search_config( request, metadata ) @@ -3295,6 +3990,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.CreateSearchConfig", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateSearchConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateSearchConfig._get_response( self._host, @@ -3316,7 +4038,29 @@ def __call__( pb_resp = warehouse.SearchConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_search_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.SearchConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.create_search_config", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateSearchConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSearchHypernym( @@ -3354,7 +4098,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchHypernym: r"""Call the create search hypernym method over HTTP. @@ -3365,8 +4109,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.SearchHypernym: @@ -3381,6 +4127,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateSearchHypernym._get_http_options() ) + request, metadata = self._interceptor.pre_create_search_hypernym( request, metadata ) @@ -3397,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.visionai_v1.WarehouseClient.CreateSearchHypernym", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateSearchHypernym", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateSearchHypernym._get_response( self._host, @@ -3418,7 +4192,29 @@ def __call__( pb_resp = warehouse.SearchHypernym.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_search_hypernym(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.SearchHypernym.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.create_search_hypernym", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateSearchHypernym", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAnnotation( @@ -3455,7 +4251,7 @@ 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 annotation method over HTTP. @@ -3466,13 +4262,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 = ( _BaseWarehouseRestTransport._BaseDeleteAnnotation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_annotation( request, metadata ) @@ -3485,6 +4284,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.DeleteAnnotation", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteAnnotation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteAnnotation._get_response( self._host, @@ -3532,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete asset method over HTTP. @@ -3542,8 +4368,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3556,6 +4384,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseDeleteAsset._get_http_options() ) + request, metadata = self._interceptor.pre_delete_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseDeleteAsset._get_transcoded_request( @@ -3570,6 +4399,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.DeleteAsset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteAsset._get_response( self._host, @@ -3588,7 +4444,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_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.delete_asset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCollection( @@ -3625,7 +4503,7 @@ 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 collection method over HTTP. @@ -3636,8 +4514,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3650,6 +4530,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseDeleteCollection._get_http_options() ) + request, metadata = self._interceptor.pre_delete_collection( request, metadata ) @@ -3662,6 +4543,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.DeleteCollection", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteCollection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteCollection._get_response( self._host, @@ -3680,7 +4588,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_collection(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.delete_collection", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteCollection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCorpus( @@ -3717,7 +4647,7 @@ 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 corpus method over HTTP. @@ -3727,13 +4657,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 = ( _BaseWarehouseRestTransport._BaseDeleteCorpus._get_http_options() ) + request, metadata = self._interceptor.pre_delete_corpus(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseDeleteCorpus._get_transcoded_request( @@ -3748,6 +4681,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.DeleteCorpus", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteCorpus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteCorpus._get_response( self._host, @@ -3797,7 +4757,7 @@ 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 data schema method over HTTP. @@ -3807,13 +4767,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 = ( _BaseWarehouseRestTransport._BaseDeleteDataSchema._get_http_options() ) + request, metadata = self._interceptor.pre_delete_data_schema( request, metadata ) @@ -3826,6 +4789,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.DeleteDataSchema", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteDataSchema", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteDataSchema._get_response( self._host, @@ -3873,7 +4863,7 @@ 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 index method over HTTP. @@ -3883,8 +4873,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3897,6 +4889,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseDeleteIndex._get_http_options() ) + request, metadata = self._interceptor.pre_delete_index(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseDeleteIndex._get_transcoded_request( @@ -3911,6 +4904,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.DeleteIndex", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteIndex", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteIndex._get_response( self._host, @@ -3929,7 +4949,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_index(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.delete_index", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteIndex", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteIndexEndpoint( @@ -3966,7 +5008,7 @@ 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 index endpoint method over HTTP. @@ -3977,8 +5019,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3991,6 +5035,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseDeleteIndexEndpoint._get_http_options() ) + request, metadata = self._interceptor.pre_delete_index_endpoint( request, metadata ) @@ -4003,6 +5048,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.DeleteIndexEndpoint", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteIndexEndpoint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteIndexEndpoint._get_response( self._host, @@ -4021,7 +5093,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_index_endpoint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.delete_index_endpoint", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteIndexEndpoint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteSearchConfig( @@ -4058,7 +5152,7 @@ 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 search config method over HTTP. @@ -4069,13 +5163,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 = ( _BaseWarehouseRestTransport._BaseDeleteSearchConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_search_config( request, metadata ) @@ -4088,6 +5185,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.DeleteSearchConfig", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteSearchConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteSearchConfig._get_response( self._host, @@ -4137,7 +5261,7 @@ 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 search hypernym method over HTTP. @@ -4148,13 +5272,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 = ( _BaseWarehouseRestTransport._BaseDeleteSearchHypernym._get_http_options() ) + request, metadata = self._interceptor.pre_delete_search_hypernym( request, metadata ) @@ -4167,6 +5294,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.DeleteSearchHypernym", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteSearchHypernym", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteSearchHypernym._get_response( self._host, @@ -4215,7 +5369,7 @@ 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 index method over HTTP. @@ -4225,8 +5379,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4239,6 +5395,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseDeployIndex._get_http_options() ) + request, metadata = self._interceptor.pre_deploy_index(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseDeployIndex._get_transcoded_request( @@ -4257,6 +5414,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.DeployIndex", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeployIndex", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeployIndex._get_response( self._host, @@ -4276,7 +5460,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_index(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.deploy_index", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeployIndex", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateHlsUri( @@ -4314,7 +5520,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.GenerateHlsUriResponse: r"""Call the generate hls uri method over HTTP. @@ -4325,8 +5531,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.GenerateHlsUriResponse: @@ -4338,6 +5546,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGenerateHlsUri._get_http_options() ) + request, metadata = self._interceptor.pre_generate_hls_uri( request, metadata ) @@ -4360,6 +5569,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.GenerateHlsUri", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GenerateHlsUri", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GenerateHlsUri._get_response( self._host, @@ -4381,7 +5617,31 @@ def __call__( pb_resp = warehouse.GenerateHlsUriResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_hls_uri(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.GenerateHlsUriResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.generate_hls_uri", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GenerateHlsUri", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateRetrievalUrl( @@ -4419,7 +5679,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.GenerateRetrievalUrlResponse: r"""Call the generate retrieval url method over HTTP. @@ -4430,8 +5690,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.GenerateRetrievalUrlResponse: @@ -4443,6 +5705,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGenerateRetrievalUrl._get_http_options() ) + request, metadata = self._interceptor.pre_generate_retrieval_url( request, metadata ) @@ -4459,6 +5722,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.GenerateRetrievalUrl", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GenerateRetrievalUrl", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GenerateRetrievalUrl._get_response( self._host, @@ -4480,7 +5770,31 @@ def __call__( pb_resp = warehouse.GenerateRetrievalUrlResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_retrieval_url(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.GenerateRetrievalUrlResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.generate_retrieval_url", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GenerateRetrievalUrl", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAnnotation( @@ -4517,7 +5831,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Call the get annotation method over HTTP. @@ -4528,8 +5842,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.Annotation: @@ -4542,6 +5858,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetAnnotation._get_http_options() ) + request, metadata = self._interceptor.pre_get_annotation(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetAnnotation._get_transcoded_request( @@ -4556,6 +5873,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.GetAnnotation", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetAnnotation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetAnnotation._get_response( self._host, @@ -4576,7 +5920,29 @@ def __call__( pb_resp = warehouse.Annotation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_annotation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Annotation.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.get_annotation", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetAnnotation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAsset(_BaseWarehouseRestTransport._BaseGetAsset, WarehouseRestStub): @@ -4611,7 +5977,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Call the get asset method over HTTP. @@ -4621,8 +5987,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.Asset: @@ -4637,6 +6005,7 @@ def __call__( """ http_options = _BaseWarehouseRestTransport._BaseGetAsset._get_http_options() + request, metadata = self._interceptor.pre_get_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetAsset._get_transcoded_request( @@ -4651,9 +6020,36 @@ def __call__( ) ) - # Send the request - response = WarehouseRestTransport._GetAsset._get_response( - self._host, + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.GetAsset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = WarehouseRestTransport._GetAsset._get_response( + self._host, metadata, query_params, self._session, @@ -4671,7 +6067,29 @@ def __call__( pb_resp = warehouse.Asset.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Asset.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.get_asset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCollection( @@ -4708,7 +6126,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Collection: r"""Call the get collection method over HTTP. @@ -4719,8 +6137,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.Collection: @@ -4733,6 +6153,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetCollection._get_http_options() ) + request, metadata = self._interceptor.pre_get_collection(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetCollection._get_transcoded_request( @@ -4747,6 +6168,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.GetCollection", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetCollection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetCollection._get_response( self._host, @@ -4767,7 +6215,29 @@ def __call__( pb_resp = warehouse.Collection.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_collection(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Collection.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.get_collection", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetCollection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCorpus(_BaseWarehouseRestTransport._BaseGetCorpus, WarehouseRestStub): @@ -4802,7 +6272,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Corpus: r"""Call the get corpus method over HTTP. @@ -4812,8 +6282,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.Corpus: @@ -4827,6 +6299,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetCorpus._get_http_options() ) + request, metadata = self._interceptor.pre_get_corpus(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetCorpus._get_transcoded_request( @@ -4841,6 +6314,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.GetCorpus", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetCorpus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetCorpus._get_response( self._host, @@ -4861,7 +6361,29 @@ def __call__( pb_resp = warehouse.Corpus.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_corpus(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Corpus.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.get_corpus", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetCorpus", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDataSchema( @@ -4898,7 +6420,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Call the get data schema method over HTTP. @@ -4908,8 +6430,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.DataSchema: @@ -4922,6 +6446,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetDataSchema._get_http_options() ) + request, metadata = self._interceptor.pre_get_data_schema(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetDataSchema._get_transcoded_request( @@ -4936,6 +6461,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.GetDataSchema", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetDataSchema", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetDataSchema._get_response( self._host, @@ -4956,7 +6508,29 @@ def __call__( pb_resp = warehouse.DataSchema.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_data_schema(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.DataSchema.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.get_data_schema", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetDataSchema", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIndex(_BaseWarehouseRestTransport._BaseGetIndex, WarehouseRestStub): @@ -4991,7 +6565,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Index: r"""Call the get index method over HTTP. @@ -5001,8 +6575,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.Index: @@ -5015,6 +6591,7 @@ def __call__( """ http_options = _BaseWarehouseRestTransport._BaseGetIndex._get_http_options() + request, metadata = self._interceptor.pre_get_index(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetIndex._get_transcoded_request( @@ -5029,6 +6606,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.GetIndex", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetIndex", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetIndex._get_response( self._host, @@ -5049,7 +6653,29 @@ def __call__( pb_resp = warehouse.Index.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_index(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Index.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.get_index", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetIndex", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIndexEndpoint( @@ -5086,7 +6712,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.IndexEndpoint: r"""Call the get index endpoint method over HTTP. @@ -5096,8 +6722,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.IndexEndpoint: @@ -5109,6 +6737,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetIndexEndpoint._get_http_options() ) + request, metadata = self._interceptor.pre_get_index_endpoint( request, metadata ) @@ -5121,6 +6750,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.GetIndexEndpoint", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetIndexEndpoint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetIndexEndpoint._get_response( self._host, @@ -5141,7 +6797,29 @@ def __call__( pb_resp = warehouse.IndexEndpoint.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_index_endpoint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.IndexEndpoint.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.get_index_endpoint", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetIndexEndpoint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSearchConfig( @@ -5178,7 +6856,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Call the get search config method over HTTP. @@ -5188,8 +6866,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.SearchConfig: @@ -5202,6 +6882,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetSearchConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_search_config( request, metadata ) @@ -5216,6 +6897,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.GetSearchConfig", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetSearchConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetSearchConfig._get_response( self._host, @@ -5236,7 +6944,29 @@ def __call__( pb_resp = warehouse.SearchConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_search_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.SearchConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.get_search_config", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetSearchConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSearchHypernym( @@ -5273,7 +7003,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchHypernym: r"""Call the get search hypernym method over HTTP. @@ -5284,8 +7014,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.SearchHypernym: @@ -5300,6 +7032,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetSearchHypernym._get_http_options() ) + request, metadata = self._interceptor.pre_get_search_hypernym( request, metadata ) @@ -5312,6 +7045,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.GetSearchHypernym", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetSearchHypernym", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetSearchHypernym._get_response( self._host, @@ -5332,7 +7092,29 @@ def __call__( pb_resp = warehouse.SearchHypernym.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_search_hypernym(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.SearchHypernym.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.get_search_hypernym", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetSearchHypernym", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportAssets( @@ -5370,7 +7152,7 @@ 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 assets method over HTTP. @@ -5380,8 +7162,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -5394,6 +7178,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseImportAssets._get_http_options() ) + request, metadata = self._interceptor.pre_import_assets(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseImportAssets._get_transcoded_request( @@ -5412,6 +7197,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.ImportAssets", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ImportAssets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ImportAssets._get_response( self._host, @@ -5431,7 +7243,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_assets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.import_assets", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ImportAssets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _IndexAsset(_BaseWarehouseRestTransport._BaseIndexAsset, WarehouseRestStub): @@ -5467,7 +7301,7 @@ 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 index asset method over HTTP. @@ -5477,8 +7311,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -5491,6 +7327,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseIndexAsset._get_http_options() ) + request, metadata = self._interceptor.pre_index_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseIndexAsset._get_transcoded_request( @@ -5509,6 +7346,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.IndexAsset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "IndexAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._IndexAsset._get_response( self._host, @@ -5528,7 +7392,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_index_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.index_asset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "IndexAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _IngestAsset(_BaseWarehouseRestTransport._BaseIngestAsset, WarehouseRestStub): @@ -5541,7 +7427,7 @@ 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 IngestAsset is not available over REST transport" @@ -5581,7 +7467,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListAnnotationsResponse: r"""Call the list annotations method over HTTP. @@ -5592,8 +7478,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.ListAnnotationsResponse: @@ -5605,6 +7493,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListAnnotations._get_http_options() ) + request, metadata = self._interceptor.pre_list_annotations( request, metadata ) @@ -5619,6 +7508,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.ListAnnotations", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListAnnotations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListAnnotations._get_response( self._host, @@ -5639,7 +7555,31 @@ def __call__( pb_resp = warehouse.ListAnnotationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_annotations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListAnnotationsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.list_annotations", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListAnnotations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAssets(_BaseWarehouseRestTransport._BaseListAssets, WarehouseRestStub): @@ -5674,7 +7614,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListAssetsResponse: r"""Call the list assets method over HTTP. @@ -5684,8 +7624,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.ListAssetsResponse: @@ -5695,6 +7637,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListAssets._get_http_options() ) + request, metadata = self._interceptor.pre_list_assets(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseListAssets._get_transcoded_request( @@ -5709,6 +7652,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.ListAssets", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListAssets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListAssets._get_response( self._host, @@ -5729,7 +7699,29 @@ def __call__( pb_resp = warehouse.ListAssetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_assets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListAssetsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.list_assets", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListAssets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCollections( @@ -5766,7 +7758,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListCollectionsResponse: r"""Call the list collections method over HTTP. @@ -5776,8 +7768,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.ListCollectionsResponse: @@ -5787,6 +7781,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListCollections._get_http_options() ) + request, metadata = self._interceptor.pre_list_collections( request, metadata ) @@ -5801,6 +7796,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.ListCollections", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListCollections", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListCollections._get_response( self._host, @@ -5821,7 +7843,31 @@ def __call__( pb_resp = warehouse.ListCollectionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_collections(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListCollectionsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.list_collections", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListCollections", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCorpora(_BaseWarehouseRestTransport._BaseListCorpora, WarehouseRestStub): @@ -5856,7 +7902,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListCorporaResponse: r"""Call the list corpora method over HTTP. @@ -5866,8 +7912,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.ListCorporaResponse: @@ -5877,6 +7925,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListCorpora._get_http_options() ) + request, metadata = self._interceptor.pre_list_corpora(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseListCorpora._get_transcoded_request( @@ -5891,6 +7940,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.ListCorpora", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListCorpora", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListCorpora._get_response( self._host, @@ -5911,7 +7987,29 @@ def __call__( pb_resp = warehouse.ListCorporaResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_corpora(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListCorporaResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.list_corpora", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListCorpora", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDataSchemas( @@ -5948,7 +8046,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListDataSchemasResponse: r"""Call the list data schemas method over HTTP. @@ -5958,8 +8056,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.ListDataSchemasResponse: @@ -5969,6 +8069,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListDataSchemas._get_http_options() ) + request, metadata = self._interceptor.pre_list_data_schemas( request, metadata ) @@ -5983,6 +8084,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.ListDataSchemas", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListDataSchemas", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListDataSchemas._get_response( self._host, @@ -6003,7 +8131,31 @@ def __call__( pb_resp = warehouse.ListDataSchemasResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_data_schemas(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListDataSchemasResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.list_data_schemas", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListDataSchemas", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListIndexEndpoints( @@ -6040,7 +8192,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListIndexEndpointsResponse: r"""Call the list index endpoints method over HTTP. @@ -6051,8 +8203,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.ListIndexEndpointsResponse: @@ -6064,6 +8218,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListIndexEndpoints._get_http_options() ) + request, metadata = self._interceptor.pre_list_index_endpoints( request, metadata ) @@ -6076,6 +8231,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.ListIndexEndpoints", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListIndexEndpoints", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListIndexEndpoints._get_response( self._host, @@ -6096,7 +8278,31 @@ def __call__( pb_resp = warehouse.ListIndexEndpointsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_index_endpoints(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListIndexEndpointsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.list_index_endpoints", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListIndexEndpoints", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListIndexes(_BaseWarehouseRestTransport._BaseListIndexes, WarehouseRestStub): @@ -6131,7 +8337,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListIndexesResponse: r"""Call the list indexes method over HTTP. @@ -6141,8 +8347,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.ListIndexesResponse: @@ -6152,6 +8360,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListIndexes._get_http_options() ) + request, metadata = self._interceptor.pre_list_indexes(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseListIndexes._get_transcoded_request( @@ -6166,6 +8375,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.ListIndexes", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListIndexes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListIndexes._get_response( self._host, @@ -6186,7 +8422,29 @@ def __call__( pb_resp = warehouse.ListIndexesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_indexes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListIndexesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.list_indexes", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListIndexes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSearchConfigs( @@ -6223,7 +8481,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListSearchConfigsResponse: r"""Call the list search configs method over HTTP. @@ -6234,8 +8492,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.ListSearchConfigsResponse: @@ -6247,6 +8507,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListSearchConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_search_configs( request, metadata ) @@ -6259,6 +8520,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.ListSearchConfigs", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListSearchConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListSearchConfigs._get_response( self._host, @@ -6279,7 +8567,31 @@ def __call__( pb_resp = warehouse.ListSearchConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_search_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListSearchConfigsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.list_search_configs", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListSearchConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSearchHypernyms( @@ -6316,7 +8628,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListSearchHypernymsResponse: r"""Call the list search hypernyms method over HTTP. @@ -6327,8 +8639,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.ListSearchHypernymsResponse: @@ -6340,6 +8654,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListSearchHypernyms._get_http_options() ) + request, metadata = self._interceptor.pre_list_search_hypernyms( request, metadata ) @@ -6352,6 +8667,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.ListSearchHypernyms", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListSearchHypernyms", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListSearchHypernyms._get_response( self._host, @@ -6372,7 +8714,31 @@ def __call__( pb_resp = warehouse.ListSearchHypernymsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_search_hypernyms(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListSearchHypernymsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.list_search_hypernyms", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListSearchHypernyms", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveCollectionItem( @@ -6410,7 +8776,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.RemoveCollectionItemResponse: r"""Call the remove collection item method over HTTP. @@ -6421,8 +8787,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.RemoveCollectionItemResponse: @@ -6434,6 +8802,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseRemoveCollectionItem._get_http_options() ) + request, metadata = self._interceptor.pre_remove_collection_item( request, metadata ) @@ -6450,6 +8819,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.RemoveCollectionItem", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "RemoveCollectionItem", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._RemoveCollectionItem._get_response( self._host, @@ -6471,7 +8867,31 @@ def __call__( pb_resp = warehouse.RemoveCollectionItemResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_collection_item(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.RemoveCollectionItemResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.remove_collection_item", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "RemoveCollectionItem", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveIndexAsset( @@ -6509,7 +8929,7 @@ 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 remove index asset method over HTTP. @@ -6519,8 +8939,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -6533,6 +8955,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseRemoveIndexAsset._get_http_options() ) + request, metadata = self._interceptor.pre_remove_index_asset( request, metadata ) @@ -6549,6 +8972,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.RemoveIndexAsset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "RemoveIndexAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._RemoveIndexAsset._get_response( self._host, @@ -6568,7 +9018,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_index_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.remove_index_asset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "RemoveIndexAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchAssets( @@ -6606,7 +9078,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchAssetsResponse: r"""Call the search assets method over HTTP. @@ -6616,8 +9088,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.SearchAssetsResponse: @@ -6627,6 +9101,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseSearchAssets._get_http_options() ) + request, metadata = self._interceptor.pre_search_assets(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseSearchAssets._get_transcoded_request( @@ -6645,6 +9120,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.SearchAssets", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "SearchAssets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._SearchAssets._get_response( self._host, @@ -6666,7 +9168,29 @@ def __call__( pb_resp = warehouse.SearchAssetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_assets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.SearchAssetsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.search_assets", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "SearchAssets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchIndexEndpoint( @@ -6704,7 +9228,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchIndexEndpointResponse: r"""Call the search index endpoint method over HTTP. @@ -6715,8 +9239,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.SearchIndexEndpointResponse: @@ -6728,6 +9254,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseSearchIndexEndpoint._get_http_options() ) + request, metadata = self._interceptor.pre_search_index_endpoint( request, metadata ) @@ -6744,6 +9271,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.SearchIndexEndpoint", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "SearchIndexEndpoint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._SearchIndexEndpoint._get_response( self._host, @@ -6765,7 +9319,31 @@ def __call__( pb_resp = warehouse.SearchIndexEndpointResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_index_endpoint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.SearchIndexEndpointResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.search_index_endpoint", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "SearchIndexEndpoint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UndeployIndex( @@ -6803,7 +9381,7 @@ 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 index method over HTTP. @@ -6814,8 +9392,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -6828,6 +9408,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUndeployIndex._get_http_options() ) + request, metadata = self._interceptor.pre_undeploy_index(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseUndeployIndex._get_transcoded_request( @@ -6848,6 +9429,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.UndeployIndex", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UndeployIndex", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UndeployIndex._get_response( self._host, @@ -6867,7 +9475,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_index(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.undeploy_index", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UndeployIndex", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAnnotation( @@ -6905,7 +9535,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Call the update annotation method over HTTP. @@ -6916,8 +9546,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.Annotation: @@ -6930,6 +9562,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateAnnotation._get_http_options() ) + request, metadata = self._interceptor.pre_update_annotation( request, metadata ) @@ -6946,6 +9579,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.UpdateAnnotation", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateAnnotation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateAnnotation._get_response( self._host, @@ -6967,7 +9627,29 @@ def __call__( pb_resp = warehouse.Annotation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_annotation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Annotation.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.update_annotation", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateAnnotation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAsset(_BaseWarehouseRestTransport._BaseUpdateAsset, WarehouseRestStub): @@ -7003,7 +9685,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Call the update asset method over HTTP. @@ -7013,8 +9695,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.Asset: @@ -7031,6 +9715,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateAsset._get_http_options() ) + request, metadata = self._interceptor.pre_update_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseUpdateAsset._get_transcoded_request( @@ -7049,6 +9734,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.UpdateAsset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateAsset._get_response( self._host, @@ -7070,7 +9782,29 @@ def __call__( pb_resp = warehouse.Asset.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Asset.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.update_asset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCollection( @@ -7108,7 +9842,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Collection: r"""Call the update collection method over HTTP. @@ -7119,8 +9853,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.Collection: @@ -7133,6 +9869,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateCollection._get_http_options() ) + request, metadata = self._interceptor.pre_update_collection( request, metadata ) @@ -7149,6 +9886,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.UpdateCollection", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateCollection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateCollection._get_response( self._host, @@ -7170,7 +9934,29 @@ def __call__( pb_resp = warehouse.Collection.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_collection(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Collection.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.update_collection", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateCollection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCorpus( @@ -7208,7 +9994,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Corpus: r"""Call the update corpus method over HTTP. @@ -7218,8 +10004,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.Corpus: @@ -7233,6 +10021,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateCorpus._get_http_options() ) + request, metadata = self._interceptor.pre_update_corpus(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseUpdateCorpus._get_transcoded_request( @@ -7251,6 +10040,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.UpdateCorpus", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateCorpus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateCorpus._get_response( self._host, @@ -7272,7 +10088,29 @@ def __call__( pb_resp = warehouse.Corpus.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_corpus(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Corpus.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.update_corpus", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateCorpus", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDataSchema( @@ -7310,7 +10148,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Call the update data schema method over HTTP. @@ -7320,8 +10158,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.DataSchema: @@ -7334,6 +10174,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateDataSchema._get_http_options() ) + request, metadata = self._interceptor.pre_update_data_schema( request, metadata ) @@ -7350,6 +10191,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.UpdateDataSchema", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateDataSchema", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateDataSchema._get_response( self._host, @@ -7371,7 +10239,29 @@ def __call__( pb_resp = warehouse.DataSchema.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_data_schema(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.DataSchema.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.update_data_schema", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateDataSchema", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateIndex(_BaseWarehouseRestTransport._BaseUpdateIndex, WarehouseRestStub): @@ -7407,7 +10297,7 @@ 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 index method over HTTP. @@ -7417,8 +10307,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -7431,6 +10323,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateIndex._get_http_options() ) + request, metadata = self._interceptor.pre_update_index(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseUpdateIndex._get_transcoded_request( @@ -7449,6 +10342,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.UpdateIndex", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateIndex", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateIndex._get_response( self._host, @@ -7468,7 +10388,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_index(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.update_index", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateIndex", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateIndexEndpoint( @@ -7506,7 +10448,7 @@ 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 index endpoint method over HTTP. @@ -7517,8 +10459,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -7531,6 +10475,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateIndexEndpoint._get_http_options() ) + request, metadata = self._interceptor.pre_update_index_endpoint( request, metadata ) @@ -7547,6 +10492,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.UpdateIndexEndpoint", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateIndexEndpoint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateIndexEndpoint._get_response( self._host, @@ -7566,7 +10538,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_index_endpoint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.update_index_endpoint", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateIndexEndpoint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSearchConfig( @@ -7604,7 +10598,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Call the update search config method over HTTP. @@ -7615,8 +10609,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.SearchConfig: @@ -7629,6 +10625,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateSearchConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_search_config( request, metadata ) @@ -7645,6 +10642,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.UpdateSearchConfig", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateSearchConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateSearchConfig._get_response( self._host, @@ -7666,7 +10690,29 @@ def __call__( pb_resp = warehouse.SearchConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_search_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.SearchConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.update_search_config", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateSearchConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSearchHypernym( @@ -7704,7 +10750,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchHypernym: r"""Call the update search hypernym method over HTTP. @@ -7715,8 +10761,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.SearchHypernym: @@ -7731,6 +10779,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateSearchHypernym._get_http_options() ) + request, metadata = self._interceptor.pre_update_search_hypernym( request, metadata ) @@ -7747,6 +10796,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.UpdateSearchHypernym", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateSearchHypernym", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateSearchHypernym._get_response( self._host, @@ -7768,7 +10844,29 @@ def __call__( pb_resp = warehouse.SearchHypernym.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_search_hypernym(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.SearchHypernym.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.update_search_hypernym", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateSearchHypernym", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UploadAsset(_BaseWarehouseRestTransport._BaseUploadAsset, WarehouseRestStub): @@ -7804,7 +10902,7 @@ 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 upload asset method over HTTP. @@ -7814,8 +10912,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -7828,6 +10928,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUploadAsset._get_http_options() ) + request, metadata = self._interceptor.pre_upload_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseUploadAsset._get_transcoded_request( @@ -7846,6 +10947,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.UploadAsset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UploadAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UploadAsset._get_response( self._host, @@ -7865,7 +10993,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_upload_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.upload_asset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UploadAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ViewCollectionItems( @@ -7902,7 +11052,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ViewCollectionItemsResponse: r"""Call the view collection items method over HTTP. @@ -7913,8 +11063,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.ViewCollectionItemsResponse: @@ -7926,6 +11078,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseViewCollectionItems._get_http_options() ) + request, metadata = self._interceptor.pre_view_collection_items( request, metadata ) @@ -7938,6 +11091,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.ViewCollectionItems", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ViewCollectionItems", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ViewCollectionItems._get_response( self._host, @@ -7958,7 +11138,31 @@ def __call__( pb_resp = warehouse.ViewCollectionItemsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_view_collection_items(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ViewCollectionItemsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.view_collection_items", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ViewCollectionItems", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ViewIndexedAssets( @@ -7995,7 +11199,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ViewIndexedAssetsResponse: r"""Call the view indexed assets method over HTTP. @@ -8006,8 +11210,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.ViewIndexedAssetsResponse: @@ -8019,6 +11225,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseViewIndexedAssets._get_http_options() ) + request, metadata = self._interceptor.pre_view_indexed_assets( request, metadata ) @@ -8031,6 +11238,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.ViewIndexedAssets", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ViewIndexedAssets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ViewIndexedAssets._get_response( self._host, @@ -8051,7 +11285,31 @@ def __call__( pb_resp = warehouse.ViewIndexedAssetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_view_indexed_assets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ViewIndexedAssetsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1.WarehouseClient.view_indexed_assets", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ViewIndexedAssets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -8611,7 +11869,7 @@ 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. @@ -8621,13 +11879,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 = ( _BaseWarehouseRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -8648,6 +11909,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.CancelOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CancelOperation._get_response( self._host, @@ -8704,7 +11992,7 @@ 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. @@ -8714,13 +12002,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 = ( _BaseWarehouseRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -8735,6 +12026,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteOperation._get_response( self._host, @@ -8790,7 +12108,7 @@ 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. @@ -8800,8 +12118,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -8810,6 +12130,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetOperation._get_transcoded_request( @@ -8824,6 +12145,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetOperation._get_response( self._host, @@ -8843,6 +12191,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.visionai_v1.WarehouseAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -8883,7 +12252,7 @@ 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. @@ -8893,8 +12262,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -8903,6 +12274,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseListOperations._get_transcoded_request( @@ -8917,6 +12289,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1.WarehouseClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListOperations._get_response( self._host, @@ -8936,6 +12335,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.visionai_v1.WarehouseAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/gapic_version.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/gapic_version.py index e9c4bb5650f3..558c8aab67c5 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/gapic_version.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/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-visionai/google/cloud/visionai_v1alpha1/services/app_platform/async_client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/async_client.py index 7a0c4c5492a9..d41efa0924cc 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/async_client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/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, AppPlatformTransport from .transports.grpc_asyncio import AppPlatformGrpcAsyncIOTransport +try: + from google.api_core import client_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 AppPlatformAsyncClient: """Service describing handlers for resources""" @@ -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.visionai_v1alpha1.AppPlatformAsyncClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "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.visionai.v1alpha1.AppPlatform", + "credentialsType": None, + }, + ) + async def list_applications( self, request: Optional[Union[platform.ListApplicationsRequest, dict]] = None, @@ -275,7 +307,7 @@ async def list_applications( 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.ListApplicationsAsyncPager: r"""Lists Applications in a given project and location. @@ -320,8 +352,10 @@ async def sample_list_applications(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListApplicationsAsyncPager: @@ -396,7 +430,7 @@ async def get_application( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Application: r"""Gets details of a single Application. @@ -437,8 +471,10 @@ async def sample_get_application(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Application: @@ -498,7 +534,7 @@ async def create_application( application: Optional[platform.Application] = None, retry: OptionalRetry = gapic_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 Application in a given project and location. @@ -554,8 +590,10 @@ async def sample_create_application(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -630,7 +668,7 @@ async def update_application( 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 Application. @@ -689,8 +727,10 @@ async def sample_update_application(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -766,7 +806,7 @@ async def delete_application( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Application. @@ -811,8 +851,10 @@ async def sample_delete_application(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -891,7 +933,7 @@ async def deploy_application( name: Optional[str] = None, retry: OptionalRetry = gapic_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 single Application. @@ -940,8 +982,10 @@ async def sample_deploy_application(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1012,7 +1056,7 @@ async def undeploy_application( name: Optional[str] = None, retry: OptionalRetry = gapic_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 single Application. @@ -1062,8 +1106,10 @@ async def sample_undeploy_application(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1137,7 +1183,7 @@ async def add_application_stream_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]]] = (), ) -> operation_async.AsyncOperation: r"""Adds target stream input to the Application. If the Application is deployed, the corresponding new @@ -1190,8 +1236,10 @@ async def sample_add_application_stream_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.api_core.operation_async.AsyncOperation: @@ -1265,7 +1313,7 @@ async def remove_application_stream_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]]] = (), ) -> operation_async.AsyncOperation: r"""Remove target stream input to the Application, if the Application is deployed, the corresponding instance @@ -1318,8 +1366,10 @@ async def sample_remove_application_stream_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.api_core.operation_async.AsyncOperation: @@ -1393,7 +1443,7 @@ async def update_application_stream_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]]] = (), ) -> operation_async.AsyncOperation: r"""Update target stream input to the Application, if the Application is deployed, the corresponding instance based will @@ -1446,8 +1496,10 @@ async def sample_update_application_stream_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.api_core.operation_async.AsyncOperation: @@ -1519,7 +1571,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 Instances in a given project and location. @@ -1564,8 +1616,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.visionai_v1alpha1.services.app_platform.pagers.ListInstancesAsyncPager: @@ -1640,7 +1694,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]]] = (), ) -> platform.Instance: r"""Gets details of a single Instance. @@ -1681,8 +1735,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.visionai_v1alpha1.types.Instance: @@ -1743,7 +1799,7 @@ async def create_application_instances( name: Optional[str] = None, retry: OptionalRetry = gapic_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 target stream input to the Application. If the Application is deployed, the corresponding new @@ -1801,8 +1857,10 @@ async def sample_create_application_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.api_core.operation_async.AsyncOperation: @@ -1876,7 +1934,7 @@ async def delete_application_instances( name: Optional[str] = None, retry: OptionalRetry = gapic_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"""Remove target stream input to the Application, if the Application is deployed, the corresponding instance @@ -1930,8 +1988,10 @@ async def sample_delete_application_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.api_core.operation_async.AsyncOperation: @@ -2010,7 +2070,7 @@ async def update_application_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]]] = (), ) -> operation_async.AsyncOperation: r"""Adds target stream input to the Application. If the Application is deployed, the corresponding new @@ -2068,8 +2128,10 @@ async def sample_update_application_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.api_core.operation_async.AsyncOperation: @@ -2143,7 +2205,7 @@ async def list_drafts( 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.ListDraftsAsyncPager: r"""Lists Drafts in a given project and location. @@ -2188,8 +2250,10 @@ async def sample_list_drafts(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListDraftsAsyncPager: @@ -2264,7 +2328,7 @@ async def get_draft( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Draft: r"""Gets details of a single Draft. @@ -2305,8 +2369,10 @@ async def sample_get_draft(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Draft: @@ -2367,7 +2433,7 @@ async def create_draft( draft_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 Draft in a given project and location. @@ -2429,8 +2495,10 @@ async def sample_create_draft(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2507,7 +2575,7 @@ async def update_draft( 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 Draft. @@ -2566,8 +2634,10 @@ async def sample_update_draft(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2643,7 +2713,7 @@ async def delete_draft( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Draft. @@ -2688,8 +2758,10 @@ async def sample_delete_draft(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2768,7 +2840,7 @@ async def list_processors( 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.ListProcessorsAsyncPager: r"""Lists Processors in a given project and location. @@ -2813,8 +2885,10 @@ async def sample_list_processors(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListProcessorsAsyncPager: @@ -2889,7 +2963,7 @@ async def list_prebuilt_processors( 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]]] = (), ) -> platform.ListPrebuiltProcessorsResponse: r"""ListPrebuiltProcessors is a custom pass-through verb that Lists Prebuilt Processors. @@ -2932,8 +3006,10 @@ async def sample_list_prebuilt_processors(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.ListPrebuiltProcessorsResponse: @@ -2994,7 +3070,7 @@ async def get_processor( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Processor: r"""Gets details of a single Processor. @@ -3035,8 +3111,10 @@ async def sample_get_processor(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Processor: @@ -3099,7 +3177,7 @@ async def create_processor( processor_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 Processor in a given project and location. @@ -3162,8 +3240,10 @@ async def sample_create_processor(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3239,7 +3319,7 @@ async def update_processor( 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 Processor. @@ -3298,8 +3378,10 @@ async def sample_update_processor(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3374,7 +3456,7 @@ async def delete_processor( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Processor. @@ -3419,8 +3501,10 @@ async def sample_delete_processor(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3498,7 +3582,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. @@ -3509,8 +3593,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. @@ -3551,7 +3637,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. @@ -3562,8 +3648,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. @@ -3604,7 +3692,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. @@ -3620,8 +3708,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 """ @@ -3658,7 +3748,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. @@ -3673,8 +3763,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 """ @@ -3711,7 +3803,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. @@ -3724,8 +3816,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. @@ -3830,7 +3924,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. @@ -3844,8 +3938,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. @@ -3950,7 +4046,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. @@ -3965,8 +4061,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. @@ -4010,7 +4108,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. @@ -4021,8 +4119,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. @@ -4063,7 +4163,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. @@ -4074,8 +4174,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-visionai/google/cloud/visionai_v1alpha1/services/app_platform/client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/client.py index 7977ca639991..382e32a19406 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/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 @@ -682,6 +692,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( @@ -744,6 +758,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.visionai_v1alpha1.AppPlatformClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "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.visionai.v1alpha1.AppPlatform", + "credentialsType": None, + }, + ) + def list_applications( self, request: Optional[Union[platform.ListApplicationsRequest, dict]] = None, @@ -751,7 +788,7 @@ def list_applications( 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.ListApplicationsPager: r"""Lists Applications in a given project and location. @@ -796,8 +833,10 @@ def sample_list_applications(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListApplicationsPager: @@ -869,7 +908,7 @@ def get_application( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Application: r"""Gets details of a single Application. @@ -910,8 +949,10 @@ def sample_get_application(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Application: @@ -968,7 +1009,7 @@ def create_application( application: Optional[platform.Application] = None, retry: OptionalRetry = gapic_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 Application in a given project and location. @@ -1024,8 +1065,10 @@ def sample_create_application(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1097,7 +1140,7 @@ def update_application( 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 Application. @@ -1156,8 +1199,10 @@ def sample_update_application(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1230,7 +1275,7 @@ def delete_application( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Application. @@ -1275,8 +1320,10 @@ def sample_delete_application(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1352,7 +1399,7 @@ def deploy_application( name: Optional[str] = None, retry: OptionalRetry = gapic_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 single Application. @@ -1401,8 +1448,10 @@ def sample_deploy_application(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1470,7 +1519,7 @@ def undeploy_application( name: Optional[str] = None, retry: OptionalRetry = gapic_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 single Application. @@ -1520,8 +1569,10 @@ def sample_undeploy_application(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1592,7 +1643,7 @@ def add_application_stream_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]]] = (), ) -> operation.Operation: r"""Adds target stream input to the Application. If the Application is deployed, the corresponding new @@ -1645,8 +1696,10 @@ def sample_add_application_stream_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.api_core.operation.Operation: @@ -1719,7 +1772,7 @@ def remove_application_stream_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]]] = (), ) -> operation.Operation: r"""Remove target stream input to the Application, if the Application is deployed, the corresponding instance @@ -1772,8 +1825,10 @@ def sample_remove_application_stream_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.api_core.operation.Operation: @@ -1846,7 +1901,7 @@ def update_application_stream_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]]] = (), ) -> operation.Operation: r"""Update target stream input to the Application, if the Application is deployed, the corresponding instance based will @@ -1899,8 +1954,10 @@ def sample_update_application_stream_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.api_core.operation.Operation: @@ -1971,7 +2028,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 Instances in a given project and location. @@ -2016,8 +2073,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.visionai_v1alpha1.services.app_platform.pagers.ListInstancesPager: @@ -2089,7 +2148,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]]] = (), ) -> platform.Instance: r"""Gets details of a single Instance. @@ -2130,8 +2189,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.visionai_v1alpha1.types.Instance: @@ -2189,7 +2250,7 @@ def create_application_instances( name: Optional[str] = None, retry: OptionalRetry = gapic_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 target stream input to the Application. If the Application is deployed, the corresponding new @@ -2247,8 +2308,10 @@ def sample_create_application_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.operation.Operation: @@ -2321,7 +2384,7 @@ def delete_application_instances( name: Optional[str] = None, retry: OptionalRetry = gapic_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"""Remove target stream input to the Application, if the Application is deployed, the corresponding instance @@ -2375,8 +2438,10 @@ def sample_delete_application_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.operation.Operation: @@ -2454,7 +2519,7 @@ def update_application_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]]] = (), ) -> operation.Operation: r"""Adds target stream input to the Application. If the Application is deployed, the corresponding new @@ -2512,8 +2577,10 @@ def sample_update_application_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.operation.Operation: @@ -2586,7 +2653,7 @@ def list_drafts( 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.ListDraftsPager: r"""Lists Drafts in a given project and location. @@ -2631,8 +2698,10 @@ def sample_list_drafts(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListDraftsPager: @@ -2704,7 +2773,7 @@ def get_draft( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Draft: r"""Gets details of a single Draft. @@ -2745,8 +2814,10 @@ def sample_get_draft(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Draft: @@ -2804,7 +2875,7 @@ def create_draft( draft_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 Draft in a given project and location. @@ -2866,8 +2937,10 @@ def sample_create_draft(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2941,7 +3014,7 @@ def update_draft( 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 Draft. @@ -3000,8 +3073,10 @@ def sample_update_draft(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3074,7 +3149,7 @@ def delete_draft( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Draft. @@ -3119,8 +3194,10 @@ def sample_delete_draft(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3196,7 +3273,7 @@ def list_processors( 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.ListProcessorsPager: r"""Lists Processors in a given project and location. @@ -3241,8 +3318,10 @@ def sample_list_processors(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListProcessorsPager: @@ -3314,7 +3393,7 @@ def list_prebuilt_processors( 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]]] = (), ) -> platform.ListPrebuiltProcessorsResponse: r"""ListPrebuiltProcessors is a custom pass-through verb that Lists Prebuilt Processors. @@ -3357,8 +3436,10 @@ def sample_list_prebuilt_processors(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.ListPrebuiltProcessorsResponse: @@ -3416,7 +3497,7 @@ def get_processor( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Processor: r"""Gets details of a single Processor. @@ -3457,8 +3538,10 @@ def sample_get_processor(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Processor: @@ -3518,7 +3601,7 @@ def create_processor( processor_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 Processor in a given project and location. @@ -3581,8 +3664,10 @@ def sample_create_processor(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3655,7 +3740,7 @@ def update_processor( 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 Processor. @@ -3714,8 +3799,10 @@ def sample_update_processor(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3787,7 +3874,7 @@ def delete_processor( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Processor. @@ -3832,8 +3919,10 @@ def sample_delete_processor(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3921,7 +4010,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. @@ -3932,8 +4021,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. @@ -3974,7 +4065,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. @@ -3985,8 +4076,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. @@ -4027,7 +4120,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. @@ -4043,8 +4136,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 """ @@ -4081,7 +4176,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. @@ -4096,8 +4191,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 """ @@ -4134,7 +4231,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. @@ -4147,8 +4244,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. @@ -4253,7 +4352,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. @@ -4267,8 +4366,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. @@ -4373,7 +4474,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. @@ -4388,8 +4489,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. @@ -4431,7 +4534,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. @@ -4442,8 +4545,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. @@ -4484,7 +4589,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. @@ -4495,8 +4600,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-visionai/google/cloud/visionai_v1alpha1/services/app_platform/pagers.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/pagers.py index 2054eb71e747..8a76e39245f5 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/pagers.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/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 = platform.ListApplicationsRequest(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 = platform.ListApplicationsRequest(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 = platform.ListInstancesRequest(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 = platform.ListInstancesRequest(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 = platform.ListDraftsRequest(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 = platform.ListDraftsRequest(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 = platform.ListProcessorsRequest(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 = platform.ListProcessorsRequest(request) diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/transports/grpc.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/transports/grpc.py index 8cdcf1d88c7e..ecb80c836547 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/transports/grpc.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/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.visionai_v1alpha1.types import platform from .base import DEFAULT_CLIENT_INFO, AppPlatformTransport +try: + from google.api_core import client_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.visionai.v1alpha1.AppPlatform", + "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.visionai.v1alpha1.AppPlatform", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AppPlatformGrpcTransport(AppPlatformTransport): """gRPC backend transport for AppPlatform. @@ -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_applications( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_applications" not in self._stubs: - self._stubs["list_applications"] = self.grpc_channel.unary_unary( + self._stubs["list_applications"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/ListApplications", request_serializer=platform.ListApplicationsRequest.serialize, response_deserializer=platform.ListApplicationsResponse.deserialize, @@ -300,7 +388,7 @@ def get_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_application" not in self._stubs: - self._stubs["get_application"] = self.grpc_channel.unary_unary( + self._stubs["get_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/GetApplication", request_serializer=platform.GetApplicationRequest.serialize, response_deserializer=platform.Application.deserialize, @@ -327,7 +415,7 @@ def create_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_application" not in self._stubs: - self._stubs["create_application"] = self.grpc_channel.unary_unary( + self._stubs["create_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/CreateApplication", request_serializer=platform.CreateApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -353,7 +441,7 @@ def update_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_application" not in self._stubs: - self._stubs["update_application"] = self.grpc_channel.unary_unary( + self._stubs["update_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/UpdateApplication", request_serializer=platform.UpdateApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -379,7 +467,7 @@ def delete_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_application" not in self._stubs: - self._stubs["delete_application"] = self.grpc_channel.unary_unary( + self._stubs["delete_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/DeleteApplication", request_serializer=platform.DeleteApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -405,7 +493,7 @@ def deploy_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "deploy_application" not in self._stubs: - self._stubs["deploy_application"] = self.grpc_channel.unary_unary( + self._stubs["deploy_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/DeployApplication", request_serializer=platform.DeployApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -431,7 +519,7 @@ def undeploy_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undeploy_application" not in self._stubs: - self._stubs["undeploy_application"] = self.grpc_channel.unary_unary( + self._stubs["undeploy_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/UndeployApplication", request_serializer=platform.UndeployApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -462,7 +550,9 @@ def add_application_stream_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_application_stream_input" not in self._stubs: - self._stubs["add_application_stream_input"] = self.grpc_channel.unary_unary( + self._stubs[ + "add_application_stream_input" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/AddApplicationStreamInput", request_serializer=platform.AddApplicationStreamInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -496,7 +586,7 @@ def remove_application_stream_input( if "remove_application_stream_input" not in self._stubs: self._stubs[ "remove_application_stream_input" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/RemoveApplicationStreamInput", request_serializer=platform.RemoveApplicationStreamInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -530,7 +620,7 @@ def update_application_stream_input( if "update_application_stream_input" not in self._stubs: self._stubs[ "update_application_stream_input" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/UpdateApplicationStreamInput", request_serializer=platform.UpdateApplicationStreamInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -556,7 +646,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.visionai.v1alpha1.AppPlatform/ListInstances", request_serializer=platform.ListInstancesRequest.serialize, response_deserializer=platform.ListInstancesResponse.deserialize, @@ -582,7 +672,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.visionai.v1alpha1.AppPlatform/GetInstance", request_serializer=platform.GetInstanceRequest.serialize, response_deserializer=platform.Instance.deserialize, @@ -613,7 +703,9 @@ def create_application_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_application_instances" not in self._stubs: - self._stubs["create_application_instances"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_application_instances" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/CreateApplicationInstances", request_serializer=platform.CreateApplicationInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -644,7 +736,9 @@ def delete_application_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_application_instances" not in self._stubs: - self._stubs["delete_application_instances"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_application_instances" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/DeleteApplicationInstances", request_serializer=platform.DeleteApplicationInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -675,7 +769,9 @@ def update_application_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_application_instances" not in self._stubs: - self._stubs["update_application_instances"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_application_instances" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/UpdateApplicationInstances", request_serializer=platform.UpdateApplicationInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -701,7 +797,7 @@ def list_drafts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_drafts" not in self._stubs: - self._stubs["list_drafts"] = self.grpc_channel.unary_unary( + self._stubs["list_drafts"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/ListDrafts", request_serializer=platform.ListDraftsRequest.serialize, response_deserializer=platform.ListDraftsResponse.deserialize, @@ -725,7 +821,7 @@ def get_draft(self) -> Callable[[platform.GetDraftRequest], platform.Draft]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_draft" not in self._stubs: - self._stubs["get_draft"] = self.grpc_channel.unary_unary( + self._stubs["get_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/GetDraft", request_serializer=platform.GetDraftRequest.serialize, response_deserializer=platform.Draft.deserialize, @@ -751,7 +847,7 @@ def create_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_draft" not in self._stubs: - self._stubs["create_draft"] = self.grpc_channel.unary_unary( + self._stubs["create_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/CreateDraft", request_serializer=platform.CreateDraftRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -777,7 +873,7 @@ def update_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_draft" not in self._stubs: - self._stubs["update_draft"] = self.grpc_channel.unary_unary( + self._stubs["update_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/UpdateDraft", request_serializer=platform.UpdateDraftRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -803,7 +899,7 @@ def delete_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_draft" not in self._stubs: - self._stubs["delete_draft"] = self.grpc_channel.unary_unary( + self._stubs["delete_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/DeleteDraft", request_serializer=platform.DeleteDraftRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -829,7 +925,7 @@ def list_processors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_processors" not in self._stubs: - self._stubs["list_processors"] = self.grpc_channel.unary_unary( + self._stubs["list_processors"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/ListProcessors", request_serializer=platform.ListProcessorsRequest.serialize, response_deserializer=platform.ListProcessorsResponse.deserialize, @@ -859,7 +955,7 @@ def list_prebuilt_processors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_prebuilt_processors" not in self._stubs: - self._stubs["list_prebuilt_processors"] = self.grpc_channel.unary_unary( + self._stubs["list_prebuilt_processors"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/ListPrebuiltProcessors", request_serializer=platform.ListPrebuiltProcessorsRequest.serialize, response_deserializer=platform.ListPrebuiltProcessorsResponse.deserialize, @@ -885,7 +981,7 @@ def get_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_processor" not in self._stubs: - self._stubs["get_processor"] = self.grpc_channel.unary_unary( + self._stubs["get_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/GetProcessor", request_serializer=platform.GetProcessorRequest.serialize, response_deserializer=platform.Processor.deserialize, @@ -912,7 +1008,7 @@ def create_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_processor" not in self._stubs: - self._stubs["create_processor"] = self.grpc_channel.unary_unary( + self._stubs["create_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/CreateProcessor", request_serializer=platform.CreateProcessorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -938,7 +1034,7 @@ def update_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_processor" not in self._stubs: - self._stubs["update_processor"] = self.grpc_channel.unary_unary( + self._stubs["update_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/UpdateProcessor", request_serializer=platform.UpdateProcessorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -964,7 +1060,7 @@ def delete_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_processor" not in self._stubs: - self._stubs["delete_processor"] = self.grpc_channel.unary_unary( + self._stubs["delete_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/DeleteProcessor", request_serializer=platform.DeleteProcessorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -972,7 +1068,7 @@ def delete_processor( return self._stubs["delete_processor"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -984,7 +1080,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, @@ -1001,7 +1097,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, @@ -1018,7 +1114,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, @@ -1037,7 +1133,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, @@ -1056,7 +1152,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, @@ -1073,7 +1169,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, @@ -1098,7 +1194,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, @@ -1124,7 +1220,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, @@ -1153,7 +1249,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-visionai/google/cloud/visionai_v1alpha1/services/app_platform/transports/grpc_asyncio.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/transports/grpc_asyncio.py index 9a9404671b30..f5a115d06522 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/transports/grpc_asyncio.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/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.visionai_v1alpha1.types import platform from .base import DEFAULT_CLIENT_INFO, AppPlatformTransport from .grpc import AppPlatformGrpcTransport +try: + from google.api_core import client_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.visionai.v1alpha1.AppPlatform", + "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.visionai.v1alpha1.AppPlatform", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AppPlatformGrpcAsyncIOTransport(AppPlatformTransport): """gRPC AsyncIO backend transport for AppPlatform. @@ -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. @@ -284,7 +369,7 @@ def list_applications( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_applications" not in self._stubs: - self._stubs["list_applications"] = self.grpc_channel.unary_unary( + self._stubs["list_applications"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/ListApplications", request_serializer=platform.ListApplicationsRequest.serialize, response_deserializer=platform.ListApplicationsResponse.deserialize, @@ -310,7 +395,7 @@ def get_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_application" not in self._stubs: - self._stubs["get_application"] = self.grpc_channel.unary_unary( + self._stubs["get_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/GetApplication", request_serializer=platform.GetApplicationRequest.serialize, response_deserializer=platform.Application.deserialize, @@ -339,7 +424,7 @@ def create_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_application" not in self._stubs: - self._stubs["create_application"] = self.grpc_channel.unary_unary( + self._stubs["create_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/CreateApplication", request_serializer=platform.CreateApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -367,7 +452,7 @@ def update_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_application" not in self._stubs: - self._stubs["update_application"] = self.grpc_channel.unary_unary( + self._stubs["update_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/UpdateApplication", request_serializer=platform.UpdateApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -395,7 +480,7 @@ def delete_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_application" not in self._stubs: - self._stubs["delete_application"] = self.grpc_channel.unary_unary( + self._stubs["delete_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/DeleteApplication", request_serializer=platform.DeleteApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -423,7 +508,7 @@ def deploy_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "deploy_application" not in self._stubs: - self._stubs["deploy_application"] = self.grpc_channel.unary_unary( + self._stubs["deploy_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/DeployApplication", request_serializer=platform.DeployApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -451,7 +536,7 @@ def undeploy_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undeploy_application" not in self._stubs: - self._stubs["undeploy_application"] = self.grpc_channel.unary_unary( + self._stubs["undeploy_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/UndeployApplication", request_serializer=platform.UndeployApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -482,7 +567,9 @@ def add_application_stream_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_application_stream_input" not in self._stubs: - self._stubs["add_application_stream_input"] = self.grpc_channel.unary_unary( + self._stubs[ + "add_application_stream_input" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/AddApplicationStreamInput", request_serializer=platform.AddApplicationStreamInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -517,7 +604,7 @@ def remove_application_stream_input( if "remove_application_stream_input" not in self._stubs: self._stubs[ "remove_application_stream_input" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/RemoveApplicationStreamInput", request_serializer=platform.RemoveApplicationStreamInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -552,7 +639,7 @@ def update_application_stream_input( if "update_application_stream_input" not in self._stubs: self._stubs[ "update_application_stream_input" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/UpdateApplicationStreamInput", request_serializer=platform.UpdateApplicationStreamInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -580,7 +667,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.visionai.v1alpha1.AppPlatform/ListInstances", request_serializer=platform.ListInstancesRequest.serialize, response_deserializer=platform.ListInstancesResponse.deserialize, @@ -606,7 +693,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.visionai.v1alpha1.AppPlatform/GetInstance", request_serializer=platform.GetInstanceRequest.serialize, response_deserializer=platform.Instance.deserialize, @@ -638,7 +725,9 @@ def create_application_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_application_instances" not in self._stubs: - self._stubs["create_application_instances"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_application_instances" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/CreateApplicationInstances", request_serializer=platform.CreateApplicationInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -670,7 +759,9 @@ def delete_application_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_application_instances" not in self._stubs: - self._stubs["delete_application_instances"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_application_instances" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/DeleteApplicationInstances", request_serializer=platform.DeleteApplicationInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -702,7 +793,9 @@ def update_application_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_application_instances" not in self._stubs: - self._stubs["update_application_instances"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_application_instances" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/UpdateApplicationInstances", request_serializer=platform.UpdateApplicationInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -728,7 +821,7 @@ def list_drafts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_drafts" not in self._stubs: - self._stubs["list_drafts"] = self.grpc_channel.unary_unary( + self._stubs["list_drafts"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/ListDrafts", request_serializer=platform.ListDraftsRequest.serialize, response_deserializer=platform.ListDraftsResponse.deserialize, @@ -754,7 +847,7 @@ def get_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_draft" not in self._stubs: - self._stubs["get_draft"] = self.grpc_channel.unary_unary( + self._stubs["get_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/GetDraft", request_serializer=platform.GetDraftRequest.serialize, response_deserializer=platform.Draft.deserialize, @@ -780,7 +873,7 @@ def create_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_draft" not in self._stubs: - self._stubs["create_draft"] = self.grpc_channel.unary_unary( + self._stubs["create_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/CreateDraft", request_serializer=platform.CreateDraftRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -806,7 +899,7 @@ def update_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_draft" not in self._stubs: - self._stubs["update_draft"] = self.grpc_channel.unary_unary( + self._stubs["update_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/UpdateDraft", request_serializer=platform.UpdateDraftRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -832,7 +925,7 @@ def delete_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_draft" not in self._stubs: - self._stubs["delete_draft"] = self.grpc_channel.unary_unary( + self._stubs["delete_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/DeleteDraft", request_serializer=platform.DeleteDraftRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -860,7 +953,7 @@ def list_processors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_processors" not in self._stubs: - self._stubs["list_processors"] = self.grpc_channel.unary_unary( + self._stubs["list_processors"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/ListProcessors", request_serializer=platform.ListProcessorsRequest.serialize, response_deserializer=platform.ListProcessorsResponse.deserialize, @@ -890,7 +983,7 @@ def list_prebuilt_processors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_prebuilt_processors" not in self._stubs: - self._stubs["list_prebuilt_processors"] = self.grpc_channel.unary_unary( + self._stubs["list_prebuilt_processors"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/ListPrebuiltProcessors", request_serializer=platform.ListPrebuiltProcessorsRequest.serialize, response_deserializer=platform.ListPrebuiltProcessorsResponse.deserialize, @@ -916,7 +1009,7 @@ def get_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_processor" not in self._stubs: - self._stubs["get_processor"] = self.grpc_channel.unary_unary( + self._stubs["get_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/GetProcessor", request_serializer=platform.GetProcessorRequest.serialize, response_deserializer=platform.Processor.deserialize, @@ -945,7 +1038,7 @@ def create_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_processor" not in self._stubs: - self._stubs["create_processor"] = self.grpc_channel.unary_unary( + self._stubs["create_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/CreateProcessor", request_serializer=platform.CreateProcessorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -973,7 +1066,7 @@ def update_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_processor" not in self._stubs: - self._stubs["update_processor"] = self.grpc_channel.unary_unary( + self._stubs["update_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/UpdateProcessor", request_serializer=platform.UpdateProcessorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1001,7 +1094,7 @@ def delete_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_processor" not in self._stubs: - self._stubs["delete_processor"] = self.grpc_channel.unary_unary( + self._stubs["delete_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/DeleteProcessor", request_serializer=platform.DeleteProcessorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1194,7 +1287,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: @@ -1210,7 +1303,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, @@ -1227,7 +1320,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, @@ -1244,7 +1337,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, @@ -1263,7 +1356,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, @@ -1282,7 +1375,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, @@ -1299,7 +1392,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, @@ -1324,7 +1417,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, @@ -1350,7 +1443,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, @@ -1379,7 +1472,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-visionai/google/cloud/visionai_v1alpha1/services/app_platform/transports/rest.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/transports/rest.py index 84a263cb72f5..cb7e4a563e90 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/transports/rest.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/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, @@ -281,8 +289,11 @@ def post_update_processor(self, response): def pre_add_application_stream_input( self, request: platform.AddApplicationStreamInputRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.AddApplicationStreamInputRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.AddApplicationStreamInputRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for add_application_stream_input Override in a subclass to manipulate the request or metadata @@ -304,8 +315,10 @@ def post_add_application_stream_input( def pre_create_application( self, request: platform.CreateApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.CreateApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.CreateApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_application Override in a subclass to manipulate the request or metadata @@ -327,8 +340,11 @@ def post_create_application( def pre_create_application_instances( self, request: platform.CreateApplicationInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.CreateApplicationInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.CreateApplicationInstancesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_application_instances Override in a subclass to manipulate the request or metadata @@ -348,8 +364,10 @@ def post_create_application_instances( return response def pre_create_draft( - self, request: platform.CreateDraftRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.CreateDraftRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.CreateDraftRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.CreateDraftRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_draft Override in a subclass to manipulate the request or metadata @@ -371,8 +389,10 @@ def post_create_draft( def pre_create_processor( self, request: platform.CreateProcessorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.CreateProcessorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.CreateProcessorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_processor Override in a subclass to manipulate the request or metadata @@ -394,8 +414,10 @@ def post_create_processor( def pre_delete_application( self, request: platform.DeleteApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.DeleteApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.DeleteApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_application Override in a subclass to manipulate the request or metadata @@ -417,8 +439,11 @@ def post_delete_application( def pre_delete_application_instances( self, request: platform.DeleteApplicationInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.DeleteApplicationInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.DeleteApplicationInstancesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_application_instances Override in a subclass to manipulate the request or metadata @@ -438,8 +463,10 @@ def post_delete_application_instances( return response def pre_delete_draft( - self, request: platform.DeleteDraftRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.DeleteDraftRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.DeleteDraftRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.DeleteDraftRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_draft Override in a subclass to manipulate the request or metadata @@ -461,8 +488,10 @@ def post_delete_draft( def pre_delete_processor( self, request: platform.DeleteProcessorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.DeleteProcessorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.DeleteProcessorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_processor Override in a subclass to manipulate the request or metadata @@ -484,8 +513,10 @@ def post_delete_processor( def pre_deploy_application( self, request: platform.DeployApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.DeployApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.DeployApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for deploy_application Override in a subclass to manipulate the request or metadata @@ -507,8 +538,8 @@ def post_deploy_application( def pre_get_application( self, request: platform.GetApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.GetApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.GetApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_application Override in a subclass to manipulate the request or metadata @@ -528,8 +559,10 @@ def post_get_application( return response def pre_get_draft( - self, request: platform.GetDraftRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.GetDraftRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.GetDraftRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.GetDraftRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_draft Override in a subclass to manipulate the request or metadata @@ -547,8 +580,10 @@ def post_get_draft(self, response: platform.Draft) -> platform.Draft: return response def pre_get_instance( - self, request: platform.GetInstanceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.GetInstanceRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.GetInstanceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.GetInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_instance Override in a subclass to manipulate the request or metadata @@ -566,8 +601,10 @@ def post_get_instance(self, response: platform.Instance) -> platform.Instance: return response def pre_get_processor( - self, request: platform.GetProcessorRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.GetProcessorRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.GetProcessorRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.GetProcessorRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_processor Override in a subclass to manipulate the request or metadata @@ -587,8 +624,10 @@ def post_get_processor(self, response: platform.Processor) -> platform.Processor def pre_list_applications( self, request: platform.ListApplicationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.ListApplicationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.ListApplicationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_applications Override in a subclass to manipulate the request or metadata @@ -608,8 +647,10 @@ def post_list_applications( return response def pre_list_drafts( - self, request: platform.ListDraftsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.ListDraftsRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.ListDraftsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.ListDraftsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_drafts Override in a subclass to manipulate the request or metadata @@ -631,8 +672,8 @@ def post_list_drafts( def pre_list_instances( self, request: platform.ListInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.ListInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.ListInstancesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_instances Override in a subclass to manipulate the request or metadata @@ -654,8 +695,10 @@ def post_list_instances( def pre_list_prebuilt_processors( self, request: platform.ListPrebuiltProcessorsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.ListPrebuiltProcessorsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.ListPrebuiltProcessorsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_prebuilt_processors Override in a subclass to manipulate the request or metadata @@ -677,8 +720,8 @@ def post_list_prebuilt_processors( def pre_list_processors( self, request: platform.ListProcessorsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.ListProcessorsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.ListProcessorsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_processors Override in a subclass to manipulate the request or metadata @@ -700,8 +743,11 @@ def post_list_processors( def pre_remove_application_stream_input( self, request: platform.RemoveApplicationStreamInputRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.RemoveApplicationStreamInputRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.RemoveApplicationStreamInputRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for remove_application_stream_input Override in a subclass to manipulate the request or metadata @@ -723,8 +769,10 @@ def post_remove_application_stream_input( def pre_undeploy_application( self, request: platform.UndeployApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.UndeployApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.UndeployApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for undeploy_application Override in a subclass to manipulate the request or metadata @@ -746,8 +794,10 @@ def post_undeploy_application( def pre_update_application( self, request: platform.UpdateApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.UpdateApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.UpdateApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_application Override in a subclass to manipulate the request or metadata @@ -769,8 +819,11 @@ def post_update_application( def pre_update_application_instances( self, request: platform.UpdateApplicationInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.UpdateApplicationInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.UpdateApplicationInstancesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_application_instances Override in a subclass to manipulate the request or metadata @@ -792,8 +845,11 @@ def post_update_application_instances( def pre_update_application_stream_input( self, request: platform.UpdateApplicationStreamInputRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.UpdateApplicationStreamInputRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.UpdateApplicationStreamInputRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_application_stream_input Override in a subclass to manipulate the request or metadata @@ -813,8 +869,10 @@ def post_update_application_stream_input( return response def pre_update_draft( - self, request: platform.UpdateDraftRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.UpdateDraftRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.UpdateDraftRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.UpdateDraftRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_draft Override in a subclass to manipulate the request or metadata @@ -836,8 +894,10 @@ def post_update_draft( def pre_update_processor( self, request: platform.UpdateProcessorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.UpdateProcessorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.UpdateProcessorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_processor Override in a subclass to manipulate the request or metadata @@ -859,8 +919,10 @@ def post_update_processor( 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 @@ -882,8 +944,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 @@ -905,8 +969,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 @@ -926,8 +992,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 @@ -947,8 +1015,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 @@ -970,8 +1041,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 @@ -991,8 +1064,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 @@ -1012,8 +1087,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 @@ -1035,8 +1112,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 @@ -1240,7 +1319,7 @@ 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 add application stream input method over HTTP. @@ -1252,8 +1331,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1266,6 +1347,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseAddApplicationStreamInput._get_http_options() ) + request, metadata = self._interceptor.pre_add_application_stream_input( request, metadata ) @@ -1282,6 +1364,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.AddApplicationStreamInput", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "AddApplicationStreamInput", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppPlatformRestTransport._AddApplicationStreamInput._get_response( @@ -1303,7 +1412,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_application_stream_input(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.AppPlatformClient.add_application_stream_input", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "AddApplicationStreamInput", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateApplication( @@ -1341,7 +1472,7 @@ 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 application method over HTTP. @@ -1351,8 +1482,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1365,6 +1498,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseCreateApplication._get_http_options() ) + request, metadata = self._interceptor.pre_create_application( request, metadata ) @@ -1381,6 +1515,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.CreateApplication", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "CreateApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._CreateApplication._get_response( self._host, @@ -1400,7 +1561,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_application(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.AppPlatformClient.create_application", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "CreateApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateApplicationInstances( @@ -1439,7 +1622,7 @@ 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 application instances method over HTTP. @@ -1451,8 +1634,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1465,6 +1650,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseCreateApplicationInstances._get_http_options() ) + request, metadata = self._interceptor.pre_create_application_instances( request, metadata ) @@ -1481,6 +1667,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.CreateApplicationInstances", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "CreateApplicationInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppPlatformRestTransport._CreateApplicationInstances._get_response( @@ -1502,7 +1715,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_application_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.AppPlatformClient.create_application_instances", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "CreateApplicationInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateDraft( @@ -1540,7 +1775,7 @@ 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 draft method over HTTP. @@ -1550,8 +1785,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1564,6 +1801,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseCreateDraft._get_http_options() ) + request, metadata = self._interceptor.pre_create_draft(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseCreateDraft._get_transcoded_request( @@ -1584,6 +1822,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.CreateDraft", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "CreateDraft", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._CreateDraft._get_response( self._host, @@ -1603,7 +1868,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_draft(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.AppPlatformClient.create_draft", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "CreateDraft", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateProcessor( @@ -1641,7 +1928,7 @@ 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 processor method over HTTP. @@ -1651,8 +1938,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1665,6 +1954,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseCreateProcessor._get_http_options() ) + request, metadata = self._interceptor.pre_create_processor( request, metadata ) @@ -1681,6 +1971,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.CreateProcessor", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "CreateProcessor", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._CreateProcessor._get_response( self._host, @@ -1700,7 +2017,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_processor(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.AppPlatformClient.create_processor", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "CreateProcessor", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteApplication( @@ -1737,7 +2076,7 @@ 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 application method over HTTP. @@ -1747,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: ~.operations_pb2.Operation: @@ -1761,6 +2102,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseDeleteApplication._get_http_options() ) + request, metadata = self._interceptor.pre_delete_application( request, metadata ) @@ -1773,6 +2115,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.DeleteApplication", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "DeleteApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._DeleteApplication._get_response( self._host, @@ -1791,7 +2160,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_application(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.AppPlatformClient.delete_application", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "DeleteApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteApplicationInstances( @@ -1830,7 +2221,7 @@ 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 application instances method over HTTP. @@ -1842,8 +2233,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1856,6 +2249,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseDeleteApplicationInstances._get_http_options() ) + request, metadata = self._interceptor.pre_delete_application_instances( request, metadata ) @@ -1872,6 +2266,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.DeleteApplicationInstances", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "DeleteApplicationInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppPlatformRestTransport._DeleteApplicationInstances._get_response( @@ -1893,7 +2314,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_application_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.AppPlatformClient.delete_application_instances", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "DeleteApplicationInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteDraft( @@ -1930,7 +2373,7 @@ 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 draft method over HTTP. @@ -1940,8 +2383,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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 +2399,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseDeleteDraft._get_http_options() ) + request, metadata = self._interceptor.pre_delete_draft(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseDeleteDraft._get_transcoded_request( @@ -1968,6 +2414,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.DeleteDraft", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "DeleteDraft", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._DeleteDraft._get_response( self._host, @@ -1986,7 +2459,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_draft(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.AppPlatformClient.delete_draft", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "DeleteDraft", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteProcessor( @@ -2023,7 +2518,7 @@ 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 processor method over HTTP. @@ -2033,8 +2528,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2047,6 +2544,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseDeleteProcessor._get_http_options() ) + request, metadata = self._interceptor.pre_delete_processor( request, metadata ) @@ -2059,6 +2557,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.DeleteProcessor", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "DeleteProcessor", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._DeleteProcessor._get_response( self._host, @@ -2077,7 +2602,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_processor(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.AppPlatformClient.delete_processor", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "DeleteProcessor", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeployApplication( @@ -2115,7 +2662,7 @@ 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 application method over HTTP. @@ -2125,8 +2672,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2139,6 +2688,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseDeployApplication._get_http_options() ) + request, metadata = self._interceptor.pre_deploy_application( request, metadata ) @@ -2155,6 +2705,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.DeployApplication", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "DeployApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._DeployApplication._get_response( self._host, @@ -2174,7 +2751,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_application(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.AppPlatformClient.deploy_application", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "DeployApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetApplication( @@ -2211,7 +2810,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Application: r"""Call the get application method over HTTP. @@ -2221,8 +2820,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.platform.Application: @@ -2232,6 +2833,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseGetApplication._get_http_options() ) + request, metadata = self._interceptor.pre_get_application(request, metadata) transcoded_request = _BaseAppPlatformRestTransport._BaseGetApplication._get_transcoded_request( http_options, request @@ -2242,6 +2844,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.GetApplication", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._GetApplication._get_response( self._host, @@ -2262,7 +2891,29 @@ def __call__( pb_resp = platform.Application.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_application(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.Application.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.AppPlatformClient.get_application", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDraft(_BaseAppPlatformRestTransport._BaseGetDraft, AppPlatformRestStub): @@ -2297,7 +2948,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Draft: r"""Call the get draft method over HTTP. @@ -2307,8 +2958,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.platform.Draft: @@ -2318,6 +2971,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseGetDraft._get_http_options() ) + request, metadata = self._interceptor.pre_get_draft(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseGetDraft._get_transcoded_request( @@ -2332,6 +2986,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.GetDraft", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetDraft", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._GetDraft._get_response( self._host, @@ -2352,7 +3033,29 @@ def __call__( pb_resp = platform.Draft.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_draft(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.Draft.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.AppPlatformClient.get_draft", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetDraft", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetInstance( @@ -2389,7 +3092,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Instance: r"""Call the get instance method over HTTP. @@ -2399,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: ~.platform.Instance: @@ -2410,6 +3115,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseGetInstance._get_http_options() ) + request, metadata = self._interceptor.pre_get_instance(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseGetInstance._get_transcoded_request( @@ -2424,6 +3130,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.GetInstance", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._GetInstance._get_response( self._host, @@ -2444,7 +3177,29 @@ def __call__( pb_resp = platform.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 = platform.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.visionai_v1alpha1.AppPlatformClient.get_instance", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetProcessor( @@ -2481,7 +3236,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Processor: r"""Call the get processor method over HTTP. @@ -2491,8 +3246,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.platform.Processor: @@ -2504,6 +3261,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseGetProcessor._get_http_options() ) + request, metadata = self._interceptor.pre_get_processor(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseGetProcessor._get_transcoded_request( @@ -2518,6 +3276,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.GetProcessor", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetProcessor", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._GetProcessor._get_response( self._host, @@ -2538,7 +3323,29 @@ def __call__( pb_resp = platform.Processor.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_processor(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.Processor.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.AppPlatformClient.get_processor", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetProcessor", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListApplications( @@ -2575,7 +3382,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.ListApplicationsResponse: r"""Call the list applications method over HTTP. @@ -2586,8 +3393,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.platform.ListApplicationsResponse: @@ -2599,6 +3408,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListApplications._get_http_options() ) + request, metadata = self._interceptor.pre_list_applications( request, metadata ) @@ -2611,6 +3421,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.ListApplications", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListApplications", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListApplications._get_response( self._host, @@ -2631,7 +3468,31 @@ def __call__( pb_resp = platform.ListApplicationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_applications(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.ListApplicationsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.AppPlatformClient.list_applications", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListApplications", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDrafts( @@ -2668,7 +3529,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.ListDraftsResponse: r"""Call the list drafts method over HTTP. @@ -2679,8 +3540,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.platform.ListDraftsResponse: @@ -2692,6 +3555,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListDrafts._get_http_options() ) + request, metadata = self._interceptor.pre_list_drafts(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseListDrafts._get_transcoded_request( @@ -2706,6 +3570,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.ListDrafts", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListDrafts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListDrafts._get_response( self._host, @@ -2726,7 +3617,29 @@ def __call__( pb_resp = platform.ListDraftsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_drafts(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.ListDraftsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.AppPlatformClient.list_drafts", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListDrafts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListInstances( @@ -2763,7 +3676,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.ListInstancesResponse: r"""Call the list instances method over HTTP. @@ -2774,8 +3687,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.platform.ListInstancesResponse: @@ -2787,6 +3702,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListInstances._get_http_options() ) + request, metadata = self._interceptor.pre_list_instances(request, metadata) transcoded_request = _BaseAppPlatformRestTransport._BaseListInstances._get_transcoded_request( http_options, request @@ -2799,6 +3715,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.ListInstances", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListInstances._get_response( self._host, @@ -2819,7 +3762,29 @@ def __call__( pb_resp = platform.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 = platform.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.visionai_v1alpha1.AppPlatformClient.list_instances", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPrebuiltProcessors( @@ -2857,7 +3822,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.ListPrebuiltProcessorsResponse: r"""Call the list prebuilt processors method over HTTP. @@ -2868,8 +3833,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.platform.ListPrebuiltProcessorsResponse: @@ -2881,6 +3848,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListPrebuiltProcessors._get_http_options() ) + request, metadata = self._interceptor.pre_list_prebuilt_processors( request, metadata ) @@ -2897,6 +3865,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.ListPrebuiltProcessors", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListPrebuiltProcessors", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListPrebuiltProcessors._get_response( self._host, @@ -2918,7 +3913,31 @@ def __call__( pb_resp = platform.ListPrebuiltProcessorsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_prebuilt_processors(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.ListPrebuiltProcessorsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.AppPlatformClient.list_prebuilt_processors", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListPrebuiltProcessors", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProcessors( @@ -2955,7 +3974,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.ListProcessorsResponse: r"""Call the list processors method over HTTP. @@ -2966,8 +3985,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.platform.ListProcessorsResponse: @@ -2979,6 +4000,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListProcessors._get_http_options() ) + request, metadata = self._interceptor.pre_list_processors(request, metadata) transcoded_request = _BaseAppPlatformRestTransport._BaseListProcessors._get_transcoded_request( http_options, request @@ -2989,6 +4011,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.ListProcessors", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListProcessors", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListProcessors._get_response( self._host, @@ -3009,7 +4058,29 @@ def __call__( pb_resp = platform.ListProcessorsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_processors(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.ListProcessorsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.AppPlatformClient.list_processors", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListProcessors", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveApplicationStreamInput( @@ -3048,7 +4119,7 @@ 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 remove application stream input method over HTTP. @@ -3060,8 +4131,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3074,6 +4147,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseRemoveApplicationStreamInput._get_http_options() ) + request, metadata = self._interceptor.pre_remove_application_stream_input( request, metadata ) @@ -3090,6 +4164,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.RemoveApplicationStreamInput", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "RemoveApplicationStreamInput", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppPlatformRestTransport._RemoveApplicationStreamInput._get_response( @@ -3111,7 +4212,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_application_stream_input(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.AppPlatformClient.remove_application_stream_input", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "RemoveApplicationStreamInput", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UndeployApplication( @@ -3149,7 +4272,7 @@ 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 application method over HTTP. @@ -3160,8 +4283,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3174,6 +4299,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseUndeployApplication._get_http_options() ) + request, metadata = self._interceptor.pre_undeploy_application( request, metadata ) @@ -3190,6 +4316,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.UndeployApplication", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "UndeployApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._UndeployApplication._get_response( self._host, @@ -3209,7 +4362,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_application(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.AppPlatformClient.undeploy_application", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "UndeployApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateApplication( @@ -3247,7 +4422,7 @@ 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 application method over HTTP. @@ -3257,8 +4432,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3271,6 +4448,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseUpdateApplication._get_http_options() ) + request, metadata = self._interceptor.pre_update_application( request, metadata ) @@ -3287,6 +4465,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.UpdateApplication", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "UpdateApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._UpdateApplication._get_response( self._host, @@ -3306,7 +4511,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_application(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.AppPlatformClient.update_application", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "UpdateApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateApplicationInstances( @@ -3345,7 +4572,7 @@ 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 application instances method over HTTP. @@ -3357,8 +4584,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3371,6 +4600,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseUpdateApplicationInstances._get_http_options() ) + request, metadata = self._interceptor.pre_update_application_instances( request, metadata ) @@ -3387,6 +4617,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.UpdateApplicationInstances", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "UpdateApplicationInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppPlatformRestTransport._UpdateApplicationInstances._get_response( @@ -3408,7 +4665,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_application_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.AppPlatformClient.update_application_instances", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "UpdateApplicationInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateApplicationStreamInput( @@ -3447,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]]] = (), ) -> operations_pb2.Operation: r"""Call the update application stream input method over HTTP. @@ -3459,8 +4738,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3473,6 +4754,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseUpdateApplicationStreamInput._get_http_options() ) + request, metadata = self._interceptor.pre_update_application_stream_input( request, metadata ) @@ -3489,6 +4771,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.UpdateApplicationStreamInput", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "UpdateApplicationStreamInput", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppPlatformRestTransport._UpdateApplicationStreamInput._get_response( @@ -3510,7 +4819,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_application_stream_input(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.AppPlatformClient.update_application_stream_input", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "UpdateApplicationStreamInput", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDraft( @@ -3548,7 +4879,7 @@ 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 draft method over HTTP. @@ -3558,8 +4889,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3572,6 +4905,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseUpdateDraft._get_http_options() ) + request, metadata = self._interceptor.pre_update_draft(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseUpdateDraft._get_transcoded_request( @@ -3592,6 +4926,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.UpdateDraft", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "UpdateDraft", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._UpdateDraft._get_response( self._host, @@ -3611,7 +4972,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_draft(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.AppPlatformClient.update_draft", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "UpdateDraft", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateProcessor( @@ -3649,7 +5032,7 @@ 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 processor method over HTTP. @@ -3659,8 +5042,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3673,6 +5058,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseUpdateProcessor._get_http_options() ) + request, metadata = self._interceptor.pre_update_processor( request, metadata ) @@ -3689,6 +5075,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.UpdateProcessor", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "UpdateProcessor", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._UpdateProcessor._get_response( self._host, @@ -3708,7 +5121,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_processor(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.AppPlatformClient.update_processor", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "UpdateProcessor", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -3972,7 +5407,7 @@ 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. @@ -3982,8 +5417,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -3992,6 +5429,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseGetLocation._get_transcoded_request( @@ -4006,6 +5444,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.GetLocation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._GetLocation._get_response( self._host, @@ -4025,6 +5490,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.visionai_v1alpha1.AppPlatformAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4065,7 +5551,7 @@ 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. @@ -4075,8 +5561,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -4085,6 +5573,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseAppPlatformRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -4097,6 +5586,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.ListLocations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListLocations._get_response( self._host, @@ -4116,6 +5632,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.visionai_v1alpha1.AppPlatformAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4156,7 +5693,7 @@ 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. @@ -4166,8 +5703,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -4176,6 +5715,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseGetIamPolicy._get_transcoded_request( @@ -4190,6 +5730,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._GetIamPolicy._get_response( self._host, @@ -4209,6 +5776,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.visionai_v1alpha1.AppPlatformAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4250,7 +5838,7 @@ 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. @@ -4260,8 +5848,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -4270,6 +5860,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseSetIamPolicy._get_transcoded_request( @@ -4290,6 +5881,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._SetIamPolicy._get_response( self._host, @@ -4310,6 +5928,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.visionai_v1alpha1.AppPlatformAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4351,7 +5990,7 @@ 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. @@ -4361,8 +6000,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -4371,6 +6012,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -4387,6 +6029,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._TestIamPermissions._get_response( self._host, @@ -4407,6 +6076,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.visionai_v1alpha1.AppPlatformAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4448,7 +6138,7 @@ 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. @@ -4458,13 +6148,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 = ( _BaseAppPlatformRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -4481,6 +6174,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.CancelOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._CancelOperation._get_response( self._host, @@ -4537,7 +6257,7 @@ 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. @@ -4547,13 +6267,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 = ( _BaseAppPlatformRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -4566,6 +6289,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._DeleteOperation._get_response( self._host, @@ -4621,7 +6371,7 @@ 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. @@ -4631,8 +6381,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -4641,6 +6393,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseGetOperation._get_transcoded_request( @@ -4655,6 +6408,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._GetOperation._get_response( self._host, @@ -4674,6 +6454,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.visionai_v1alpha1.AppPlatformAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4714,7 +6515,7 @@ 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. @@ -4724,8 +6525,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -4734,6 +6537,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseAppPlatformRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -4744,6 +6548,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.AppPlatformClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListOperations._get_response( self._host, @@ -4763,6 +6594,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.visionai_v1alpha1.AppPlatformAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/async_client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/async_client.py index 629dc53b632c..aec2f29da09b 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/async_client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/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, LiveVideoAnalyticsTransport from .transports.grpc_asyncio import LiveVideoAnalyticsGrpcAsyncIOTransport +try: + from google.api_core import client_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 LiveVideoAnalyticsAsyncClient: """Service describing handlers for resources. The service @@ -273,6 +283,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.visionai_v1alpha1.LiveVideoAnalyticsAsyncClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "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.visionai.v1alpha1.LiveVideoAnalytics", + "credentialsType": None, + }, + ) + async def list_analyses( self, request: Optional[Union[lva_service.ListAnalysesRequest, dict]] = None, @@ -280,7 +312,7 @@ async def list_analyses( 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.ListAnalysesAsyncPager: r"""Lists Analyses in a given project and location. @@ -325,8 +357,10 @@ async def sample_list_analyses(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.services.live_video_analytics.pagers.ListAnalysesAsyncPager: @@ -401,7 +435,7 @@ async def get_analysis( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_resources.Analysis: r"""Gets details of a single Analysis. @@ -442,8 +476,10 @@ async def sample_get_analysis(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Analysis: @@ -506,7 +542,7 @@ async def create_analysis( analysis_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 Analysis in a given project and location. @@ -565,8 +601,10 @@ async def sample_create_analysis(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -643,7 +681,7 @@ async def update_analysis( 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 Analysis. @@ -698,8 +736,10 @@ async def sample_update_analysis(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -775,7 +815,7 @@ async def delete_analysis( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Analysis. @@ -820,8 +860,10 @@ async def sample_delete_analysis(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -899,7 +941,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. @@ -910,8 +952,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. @@ -952,7 +996,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. @@ -963,8 +1007,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. @@ -1005,7 +1051,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. @@ -1021,8 +1067,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 """ @@ -1059,7 +1107,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. @@ -1074,8 +1122,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 """ @@ -1112,7 +1162,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. @@ -1125,8 +1175,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. @@ -1231,7 +1283,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. @@ -1245,8 +1297,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. @@ -1351,7 +1405,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. @@ -1366,8 +1420,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. @@ -1411,7 +1467,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. @@ -1422,8 +1478,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. @@ -1464,7 +1522,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. @@ -1475,8 +1533,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-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/client.py index 69debadc828b..4fe984f02f39 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/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 @@ -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( @@ -685,6 +699,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.visionai_v1alpha1.LiveVideoAnalyticsClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "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.visionai.v1alpha1.LiveVideoAnalytics", + "credentialsType": None, + }, + ) + def list_analyses( self, request: Optional[Union[lva_service.ListAnalysesRequest, dict]] = None, @@ -692,7 +729,7 @@ def list_analyses( 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.ListAnalysesPager: r"""Lists Analyses in a given project and location. @@ -737,8 +774,10 @@ def sample_list_analyses(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.services.live_video_analytics.pagers.ListAnalysesPager: @@ -810,7 +849,7 @@ def get_analysis( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_resources.Analysis: r"""Gets details of a single Analysis. @@ -851,8 +890,10 @@ def sample_get_analysis(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Analysis: @@ -912,7 +953,7 @@ def create_analysis( analysis_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 Analysis in a given project and location. @@ -971,8 +1012,10 @@ def sample_create_analysis(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1046,7 +1089,7 @@ def update_analysis( 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 Analysis. @@ -1101,8 +1144,10 @@ def sample_update_analysis(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1175,7 +1220,7 @@ def delete_analysis( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Analysis. @@ -1220,8 +1265,10 @@ def sample_delete_analysis(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1309,7 +1356,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. @@ -1320,8 +1367,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. @@ -1362,7 +1411,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. @@ -1373,8 +1422,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. @@ -1415,7 +1466,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. @@ -1431,8 +1482,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 """ @@ -1469,7 +1522,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. @@ -1484,8 +1537,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 """ @@ -1522,7 +1577,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. @@ -1535,8 +1590,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. @@ -1641,7 +1698,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. @@ -1655,8 +1712,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. @@ -1761,7 +1820,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. @@ -1776,8 +1835,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. @@ -1819,7 +1880,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. @@ -1830,8 +1891,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. @@ -1872,7 +1935,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. @@ -1883,8 +1946,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-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/pagers.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/pagers.py index 86ab91db0b6a..38fe9ab3f6af 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/pagers.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/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 = lva_service.ListAnalysesRequest(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 = lva_service.ListAnalysesRequest(request) diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/transports/grpc.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/transports/grpc.py index 76d537ed3e38..3637d416107b 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/transports/grpc.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/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.visionai_v1alpha1.types import lva_resources, lva_service from .base import DEFAULT_CLIENT_INFO, LiveVideoAnalyticsTransport +try: + from google.api_core import client_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.visionai.v1alpha1.LiveVideoAnalytics", + "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.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class LiveVideoAnalyticsGrpcTransport(LiveVideoAnalyticsTransport): """gRPC backend transport for LiveVideoAnalytics. @@ -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 @@ -274,7 +362,7 @@ def list_analyses( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_analyses" not in self._stubs: - self._stubs["list_analyses"] = self.grpc_channel.unary_unary( + self._stubs["list_analyses"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.LiveVideoAnalytics/ListAnalyses", request_serializer=lva_service.ListAnalysesRequest.serialize, response_deserializer=lva_service.ListAnalysesResponse.deserialize, @@ -300,7 +388,7 @@ def get_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_analysis" not in self._stubs: - self._stubs["get_analysis"] = self.grpc_channel.unary_unary( + self._stubs["get_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.LiveVideoAnalytics/GetAnalysis", request_serializer=lva_service.GetAnalysisRequest.serialize, response_deserializer=lva_resources.Analysis.deserialize, @@ -327,7 +415,7 @@ def create_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_analysis" not in self._stubs: - self._stubs["create_analysis"] = self.grpc_channel.unary_unary( + self._stubs["create_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.LiveVideoAnalytics/CreateAnalysis", request_serializer=lva_service.CreateAnalysisRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -353,7 +441,7 @@ def update_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_analysis" not in self._stubs: - self._stubs["update_analysis"] = self.grpc_channel.unary_unary( + self._stubs["update_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.LiveVideoAnalytics/UpdateAnalysis", request_serializer=lva_service.UpdateAnalysisRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -379,7 +467,7 @@ def delete_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_analysis" not in self._stubs: - self._stubs["delete_analysis"] = self.grpc_channel.unary_unary( + self._stubs["delete_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.LiveVideoAnalytics/DeleteAnalysis", request_serializer=lva_service.DeleteAnalysisRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -387,7 +475,7 @@ def delete_analysis( return self._stubs["delete_analysis"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -399,7 +487,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, @@ -416,7 +504,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, @@ -433,7 +521,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, @@ -452,7 +540,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, @@ -471,7 +559,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, @@ -488,7 +576,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, @@ -513,7 +601,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, @@ -539,7 +627,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, @@ -568,7 +656,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-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/transports/grpc_asyncio.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/transports/grpc_asyncio.py index 62d4d743c1e8..7bcc81ade48d 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/transports/grpc_asyncio.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/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.visionai_v1alpha1.types import lva_resources, lva_service from .base import DEFAULT_CLIENT_INFO, LiveVideoAnalyticsTransport from .grpc import LiveVideoAnalyticsGrpcTransport +try: + from google.api_core import client_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.visionai.v1alpha1.LiveVideoAnalytics", + "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.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class LiveVideoAnalyticsGrpcAsyncIOTransport(LiveVideoAnalyticsTransport): """gRPC AsyncIO backend transport for LiveVideoAnalytics. @@ -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. @@ -286,7 +371,7 @@ def list_analyses( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_analyses" not in self._stubs: - self._stubs["list_analyses"] = self.grpc_channel.unary_unary( + self._stubs["list_analyses"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.LiveVideoAnalytics/ListAnalyses", request_serializer=lva_service.ListAnalysesRequest.serialize, response_deserializer=lva_service.ListAnalysesResponse.deserialize, @@ -312,7 +397,7 @@ def get_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_analysis" not in self._stubs: - self._stubs["get_analysis"] = self.grpc_channel.unary_unary( + self._stubs["get_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.LiveVideoAnalytics/GetAnalysis", request_serializer=lva_service.GetAnalysisRequest.serialize, response_deserializer=lva_resources.Analysis.deserialize, @@ -341,7 +426,7 @@ def create_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_analysis" not in self._stubs: - self._stubs["create_analysis"] = self.grpc_channel.unary_unary( + self._stubs["create_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.LiveVideoAnalytics/CreateAnalysis", request_serializer=lva_service.CreateAnalysisRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -369,7 +454,7 @@ def update_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_analysis" not in self._stubs: - self._stubs["update_analysis"] = self.grpc_channel.unary_unary( + self._stubs["update_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.LiveVideoAnalytics/UpdateAnalysis", request_serializer=lva_service.UpdateAnalysisRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -397,7 +482,7 @@ def delete_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_analysis" not in self._stubs: - self._stubs["delete_analysis"] = self.grpc_channel.unary_unary( + self._stubs["delete_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.LiveVideoAnalytics/DeleteAnalysis", request_serializer=lva_service.DeleteAnalysisRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -485,7 +570,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: @@ -501,7 +586,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, @@ -518,7 +603,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, @@ -535,7 +620,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, @@ -554,7 +639,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, @@ -573,7 +658,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, @@ -590,7 +675,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, @@ -615,7 +700,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, @@ -641,7 +726,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, @@ -670,7 +755,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-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/transports/rest.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/transports/rest.py index 14e008ef9d7a..9726c2f9f2da 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/transports/rest.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/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_analysis(self, response): def pre_create_analysis( self, request: lva_service.CreateAnalysisRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.CreateAnalysisRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.CreateAnalysisRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_analysis Override in a subclass to manipulate the request or metadata @@ -136,8 +146,10 @@ def post_create_analysis( def pre_delete_analysis( self, request: lva_service.DeleteAnalysisRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.DeleteAnalysisRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.DeleteAnalysisRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_analysis Override in a subclass to manipulate the request or metadata @@ -159,8 +171,8 @@ def post_delete_analysis( def pre_get_analysis( self, request: lva_service.GetAnalysisRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.GetAnalysisRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[lva_service.GetAnalysisRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_analysis Override in a subclass to manipulate the request or metadata @@ -182,8 +194,10 @@ def post_get_analysis( def pre_list_analyses( self, request: lva_service.ListAnalysesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.ListAnalysesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.ListAnalysesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_analyses Override in a subclass to manipulate the request or metadata @@ -205,8 +219,10 @@ def post_list_analyses( def pre_update_analysis( self, request: lva_service.UpdateAnalysisRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.UpdateAnalysisRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.UpdateAnalysisRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_analysis Override in a subclass to manipulate the request or metadata @@ -228,8 +244,10 @@ def post_update_analysis( 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 @@ -251,8 +269,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 @@ -274,8 +294,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 @@ -295,8 +317,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 @@ -316,8 +340,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 @@ -339,8 +366,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 @@ -360,8 +389,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 @@ -381,8 +412,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 @@ -404,8 +437,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 @@ -611,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create analysis method over HTTP. @@ -621,8 +656,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -635,6 +672,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseCreateAnalysis._get_http_options() ) + request, metadata = self._interceptor.pre_create_analysis(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseCreateAnalysis._get_transcoded_request( http_options, request @@ -649,6 +687,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.LiveVideoAnalyticsClient.CreateAnalysis", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "CreateAnalysis", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._CreateAnalysis._get_response( self._host, @@ -668,7 +733,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_analysis(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.LiveVideoAnalyticsClient.create_analysis", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "CreateAnalysis", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAnalysis( @@ -706,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete analysis method over HTTP. @@ -716,8 +803,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -730,6 +819,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseDeleteAnalysis._get_http_options() ) + request, metadata = self._interceptor.pre_delete_analysis(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseDeleteAnalysis._get_transcoded_request( http_options, request @@ -740,6 +830,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.LiveVideoAnalyticsClient.DeleteAnalysis", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "DeleteAnalysis", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._DeleteAnalysis._get_response( self._host, @@ -758,7 +875,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_analysis(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.LiveVideoAnalyticsClient.delete_analysis", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "DeleteAnalysis", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAnalysis( @@ -796,7 +935,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_resources.Analysis: r"""Call the get analysis method over HTTP. @@ -806,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: ~.lva_resources.Analysis: @@ -819,6 +960,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseGetAnalysis._get_http_options() ) + request, metadata = self._interceptor.pre_get_analysis(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseGetAnalysis._get_transcoded_request( http_options, request @@ -829,6 +971,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.LiveVideoAnalyticsClient.GetAnalysis", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "GetAnalysis", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._GetAnalysis._get_response( self._host, @@ -849,7 +1018,29 @@ def __call__( pb_resp = lva_resources.Analysis.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_analysis(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = lva_resources.Analysis.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.LiveVideoAnalyticsClient.get_analysis", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "GetAnalysis", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAnalyses( @@ -887,7 +1078,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_service.ListAnalysesResponse: r"""Call the list analyses method over HTTP. @@ -898,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: ~.lva_service.ListAnalysesResponse: @@ -911,6 +1104,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseListAnalyses._get_http_options() ) + request, metadata = self._interceptor.pre_list_analyses(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseListAnalyses._get_transcoded_request( http_options, request @@ -921,6 +1115,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.LiveVideoAnalyticsClient.ListAnalyses", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "ListAnalyses", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._ListAnalyses._get_response( self._host, @@ -941,7 +1162,31 @@ def __call__( pb_resp = lva_service.ListAnalysesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_analyses(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = lva_service.ListAnalysesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.LiveVideoAnalyticsClient.list_analyses", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "ListAnalyses", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAnalysis( @@ -980,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]]] = (), ) -> operations_pb2.Operation: r"""Call the update analysis method over HTTP. @@ -990,8 +1235,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1004,6 +1251,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseUpdateAnalysis._get_http_options() ) + request, metadata = self._interceptor.pre_update_analysis(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseUpdateAnalysis._get_transcoded_request( http_options, request @@ -1018,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.LiveVideoAnalyticsClient.UpdateAnalysis", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "UpdateAnalysis", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._UpdateAnalysis._get_response( self._host, @@ -1037,7 +1312,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_analysis(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.LiveVideoAnalyticsClient.update_analysis", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "UpdateAnalysis", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1119,7 +1416,7 @@ 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. @@ -1129,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: locations_pb2.Location: Response from GetLocation method. @@ -1139,6 +1438,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1149,6 +1449,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.LiveVideoAnalyticsClient.GetLocation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._GetLocation._get_response( self._host, @@ -1168,6 +1495,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.visionai_v1alpha1.LiveVideoAnalyticsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1209,7 +1557,7 @@ 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. @@ -1219,8 +1567,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1229,6 +1579,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1239,6 +1590,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.LiveVideoAnalyticsClient.ListLocations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._ListLocations._get_response( self._host, @@ -1258,6 +1636,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.visionai_v1alpha1.LiveVideoAnalyticsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1299,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]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -1309,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: policy_pb2.Policy: Response from GetIamPolicy method. @@ -1319,6 +1720,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -1329,6 +1731,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.LiveVideoAnalyticsClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._GetIamPolicy._get_response( self._host, @@ -1348,6 +1777,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.visionai_v1alpha1.LiveVideoAnalyticsAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1390,7 +1840,7 @@ 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. @@ -1400,8 +1850,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1410,6 +1862,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -1424,6 +1877,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.LiveVideoAnalyticsClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._SetIamPolicy._get_response( self._host, @@ -1444,6 +1924,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.visionai_v1alpha1.LiveVideoAnalyticsAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1486,7 +1987,7 @@ 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. @@ -1496,8 +1997,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1506,6 +2009,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1522,6 +2026,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.LiveVideoAnalyticsClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( LiveVideoAnalyticsRestTransport._TestIamPermissions._get_response( @@ -1544,6 +2075,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.visionai_v1alpha1.LiveVideoAnalyticsAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1586,7 +2138,7 @@ 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. @@ -1596,13 +2148,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 = ( _BaseLiveVideoAnalyticsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1619,6 +2174,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.LiveVideoAnalyticsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._CancelOperation._get_response( self._host, @@ -1676,7 +2258,7 @@ 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. @@ -1686,13 +2268,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 = ( _BaseLiveVideoAnalyticsRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1705,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.visionai_v1alpha1.LiveVideoAnalyticsClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._DeleteOperation._get_response( self._host, @@ -1761,7 +2373,7 @@ 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. @@ -1771,8 +2383,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -1781,6 +2395,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1791,6 +2406,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.LiveVideoAnalyticsClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._GetOperation._get_response( self._host, @@ -1810,6 +2452,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.visionai_v1alpha1.LiveVideoAnalyticsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1851,7 +2514,7 @@ 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. @@ -1861,8 +2524,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -1871,6 +2536,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1881,6 +2547,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.LiveVideoAnalyticsClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._ListOperations._get_response( self._host, @@ -1900,6 +2593,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.visionai_v1alpha1.LiveVideoAnalyticsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/async_client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/async_client.py index 0fea8f23bb26..4a4d31fef714 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/async_client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_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 ( AsyncIterable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, StreamingServiceTransport from .transports.grpc_asyncio import StreamingServiceGrpcAsyncIOTransport +try: + from google.api_core import client_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 StreamingServiceAsyncClient: """Streaming service for receiving and sending packets.""" @@ -264,13 +274,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.visionai_v1alpha1.StreamingServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "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.visionai.v1alpha1.StreamingService", + "credentialsType": None, + }, + ) + def send_packets( self, requests: Optional[AsyncIterator[streaming_service.SendPacketsRequest]] = None, *, retry: OptionalRetry = 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[streaming_service.SendPacketsResponse]]: r"""Send packets to the series. @@ -316,8 +348,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.visionai_v1alpha1.types.SendPacketsResponse]: @@ -352,7 +386,7 @@ def receive_packets( *, retry: OptionalRetry = 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[streaming_service.ReceivePacketsResponse]]: r"""Receive packets from the series. @@ -399,8 +433,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.visionai_v1alpha1.types.ReceivePacketsResponse]: @@ -435,7 +471,7 @@ def receive_events( *, retry: OptionalRetry = 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[streaming_service.ReceiveEventsResponse]]: r"""Receive events given the stream name. @@ -481,8 +517,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.visionai_v1alpha1.types.ReceiveEventsResponse]: @@ -517,7 +555,7 @@ async def acquire_lease( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.Lease: r"""AcquireLease acquires a lease. @@ -553,8 +591,10 @@ async def sample_acquire_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.visionai_v1alpha1.types.Lease: @@ -598,7 +638,7 @@ async def renew_lease( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.Lease: r"""RenewLease renews a lease. @@ -633,8 +673,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.visionai_v1alpha1.types.Lease: @@ -678,7 +720,7 @@ async def release_lease( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.ReleaseLeaseResponse: r"""RleaseLease releases a lease. @@ -713,8 +755,10 @@ async def sample_release_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.visionai_v1alpha1.types.ReleaseLeaseResponse: @@ -758,7 +802,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. @@ -769,8 +813,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. @@ -811,7 +857,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. @@ -822,8 +868,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. @@ -864,7 +912,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. @@ -880,8 +928,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 """ @@ -918,7 +968,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. @@ -933,8 +983,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 """ @@ -971,7 +1023,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. @@ -984,8 +1036,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. @@ -1090,7 +1144,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. @@ -1104,8 +1158,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. @@ -1210,7 +1266,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. @@ -1225,8 +1281,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. @@ -1270,7 +1328,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. @@ -1281,8 +1339,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. @@ -1323,7 +1383,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. @@ -1334,8 +1394,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-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/client.py index 5a7b337ee0ce..0a371a4072da 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_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 ( @@ -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.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_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,13 +669,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.visionai_v1alpha1.StreamingServiceClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "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.visionai.v1alpha1.StreamingService", + "credentialsType": None, + }, + ) + def send_packets( self, requests: Optional[Iterator[streaming_service.SendPacketsRequest]] = None, *, retry: OptionalRetry = 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[streaming_service.SendPacketsResponse]: r"""Send packets to the series. @@ -707,8 +744,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.visionai_v1alpha1.types.SendPacketsResponse]: @@ -739,7 +778,7 @@ def receive_packets( *, retry: OptionalRetry = 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[streaming_service.ReceivePacketsResponse]: r"""Receive packets from the series. @@ -786,8 +825,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.visionai_v1alpha1.types.ReceivePacketsResponse]: @@ -818,7 +859,7 @@ def receive_events( *, retry: OptionalRetry = 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[streaming_service.ReceiveEventsResponse]: r"""Receive events given the stream name. @@ -864,8 +905,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.visionai_v1alpha1.types.ReceiveEventsResponse]: @@ -898,7 +941,7 @@ def acquire_lease( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.Lease: r"""AcquireLease acquires a lease. @@ -934,8 +977,10 @@ def sample_acquire_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.visionai_v1alpha1.types.Lease: @@ -977,7 +1022,7 @@ def renew_lease( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.Lease: r"""RenewLease renews a lease. @@ -1012,8 +1057,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.visionai_v1alpha1.types.Lease: @@ -1055,7 +1102,7 @@ def release_lease( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.ReleaseLeaseResponse: r"""RleaseLease releases a lease. @@ -1090,8 +1137,10 @@ def sample_release_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.visionai_v1alpha1.types.ReleaseLeaseResponse: @@ -1146,7 +1195,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. @@ -1157,8 +1206,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. @@ -1199,7 +1250,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. @@ -1210,8 +1261,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. @@ -1252,7 +1305,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. @@ -1268,8 +1321,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 """ @@ -1306,7 +1361,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. @@ -1321,8 +1376,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 """ @@ -1359,7 +1416,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. @@ -1372,8 +1429,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. @@ -1478,7 +1537,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. @@ -1492,8 +1551,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. @@ -1598,7 +1659,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. @@ -1613,8 +1674,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. @@ -1656,7 +1719,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. @@ -1667,8 +1730,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. @@ -1709,7 +1774,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. @@ -1720,8 +1785,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-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/transports/grpc.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/transports/grpc.py index b5fb15898863..5ef98e1c674d 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/transports/grpc.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_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.visionai_v1alpha1.types import streaming_service from .base import DEFAULT_CLIENT_INFO, StreamingServiceTransport +try: + from google.api_core import client_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.visionai.v1alpha1.StreamingService", + "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.visionai.v1alpha1.StreamingService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StreamingServiceGrpcTransport(StreamingServiceTransport): """gRPC backend transport for StreamingService. @@ -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 send_packets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "send_packets" not in self._stubs: - self._stubs["send_packets"] = self.grpc_channel.stream_stream( + self._stubs["send_packets"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1alpha1.StreamingService/SendPackets", request_serializer=streaming_service.SendPacketsRequest.serialize, response_deserializer=streaming_service.SendPacketsResponse.deserialize, @@ -288,7 +374,7 @@ def receive_packets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "receive_packets" not in self._stubs: - self._stubs["receive_packets"] = self.grpc_channel.stream_stream( + self._stubs["receive_packets"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1alpha1.StreamingService/ReceivePackets", request_serializer=streaming_service.ReceivePacketsRequest.serialize, response_deserializer=streaming_service.ReceivePacketsResponse.deserialize, @@ -317,7 +403,7 @@ def receive_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "receive_events" not in self._stubs: - self._stubs["receive_events"] = self.grpc_channel.stream_stream( + self._stubs["receive_events"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1alpha1.StreamingService/ReceiveEvents", request_serializer=streaming_service.ReceiveEventsRequest.serialize, response_deserializer=streaming_service.ReceiveEventsResponse.deserialize, @@ -343,7 +429,7 @@ def acquire_lease( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "acquire_lease" not in self._stubs: - self._stubs["acquire_lease"] = self.grpc_channel.unary_unary( + self._stubs["acquire_lease"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamingService/AcquireLease", request_serializer=streaming_service.AcquireLeaseRequest.serialize, response_deserializer=streaming_service.Lease.deserialize, @@ -369,7 +455,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.visionai.v1alpha1.StreamingService/RenewLease", request_serializer=streaming_service.RenewLeaseRequest.serialize, response_deserializer=streaming_service.Lease.deserialize, @@ -397,7 +483,7 @@ def release_lease( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "release_lease" not in self._stubs: - self._stubs["release_lease"] = self.grpc_channel.unary_unary( + self._stubs["release_lease"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamingService/ReleaseLease", request_serializer=streaming_service.ReleaseLeaseRequest.serialize, response_deserializer=streaming_service.ReleaseLeaseResponse.deserialize, @@ -405,7 +491,7 @@ def release_lease( return self._stubs["release_lease"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -417,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, @@ -434,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, @@ -451,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, @@ -470,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, @@ -489,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, @@ -506,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, @@ -531,7 +617,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, @@ -557,7 +643,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, @@ -586,7 +672,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-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/transports/grpc_asyncio.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/transports/grpc_asyncio.py index 158936493ded..8a3bc5d3f369 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_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.visionai_v1alpha1.types import streaming_service from .base import DEFAULT_CLIENT_INFO, StreamingServiceTransport from .grpc import StreamingServiceGrpcTransport +try: + from google.api_core import client_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.visionai.v1alpha1.StreamingService", + "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.visionai.v1alpha1.StreamingService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StreamingServiceGrpcAsyncIOTransport(StreamingServiceTransport): """gRPC AsyncIO backend transport for StreamingService. @@ -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 send_packets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "send_packets" not in self._stubs: - self._stubs["send_packets"] = self.grpc_channel.stream_stream( + self._stubs["send_packets"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1alpha1.StreamingService/SendPackets", request_serializer=streaming_service.SendPacketsRequest.serialize, response_deserializer=streaming_service.SendPacketsResponse.deserialize, @@ -297,7 +382,7 @@ def receive_packets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "receive_packets" not in self._stubs: - self._stubs["receive_packets"] = self.grpc_channel.stream_stream( + self._stubs["receive_packets"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1alpha1.StreamingService/ReceivePackets", request_serializer=streaming_service.ReceivePacketsRequest.serialize, response_deserializer=streaming_service.ReceivePacketsResponse.deserialize, @@ -326,7 +411,7 @@ def receive_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "receive_events" not in self._stubs: - self._stubs["receive_events"] = self.grpc_channel.stream_stream( + self._stubs["receive_events"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1alpha1.StreamingService/ReceiveEvents", request_serializer=streaming_service.ReceiveEventsRequest.serialize, response_deserializer=streaming_service.ReceiveEventsResponse.deserialize, @@ -354,7 +439,7 @@ def acquire_lease( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "acquire_lease" not in self._stubs: - self._stubs["acquire_lease"] = self.grpc_channel.unary_unary( + self._stubs["acquire_lease"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamingService/AcquireLease", request_serializer=streaming_service.AcquireLeaseRequest.serialize, response_deserializer=streaming_service.Lease.deserialize, @@ -382,7 +467,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.visionai.v1alpha1.StreamingService/RenewLease", request_serializer=streaming_service.RenewLeaseRequest.serialize, response_deserializer=streaming_service.Lease.deserialize, @@ -411,7 +496,7 @@ def release_lease( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "release_lease" not in self._stubs: - self._stubs["release_lease"] = self.grpc_channel.unary_unary( + self._stubs["release_lease"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamingService/ReleaseLease", request_serializer=streaming_service.ReleaseLeaseRequest.serialize, response_deserializer=streaming_service.ReleaseLeaseResponse.deserialize, @@ -504,7 +589,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: @@ -520,7 +605,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, @@ -537,7 +622,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, @@ -554,7 +639,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, @@ -573,7 +658,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, @@ -592,7 +677,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, @@ -609,7 +694,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, @@ -634,7 +719,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, @@ -660,7 +745,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, @@ -689,7 +774,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-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/transports/rest.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/transports/rest.py index 91e8bc6e11c3..23b0d32277e5 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/transports/rest.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_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, @@ -97,8 +105,10 @@ def post_renew_lease(self, response): def pre_acquire_lease( self, request: streaming_service.AcquireLeaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streaming_service.AcquireLeaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streaming_service.AcquireLeaseRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for acquire_lease Override in a subclass to manipulate the request or metadata @@ -120,8 +130,10 @@ def post_acquire_lease( def pre_release_lease( self, request: streaming_service.ReleaseLeaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streaming_service.ReleaseLeaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streaming_service.ReleaseLeaseRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for release_lease Override in a subclass to manipulate the request or metadata @@ -143,8 +155,10 @@ def post_release_lease( def pre_renew_lease( self, request: streaming_service.RenewLeaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streaming_service.RenewLeaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streaming_service.RenewLeaseRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for renew_lease Override in a subclass to manipulate the request or metadata @@ -166,8 +180,10 @@ def post_renew_lease( 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 @@ -189,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 @@ -212,8 +230,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 @@ -233,8 +253,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 @@ -254,8 +276,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 @@ -277,8 +302,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 @@ -298,8 +325,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 @@ -319,8 +348,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 @@ -342,8 +373,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 @@ -484,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]]] = (), ) -> streaming_service.Lease: r"""Call the acquire lease method over HTTP. @@ -495,8 +528,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.streaming_service.Lease: @@ -506,6 +541,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseAcquireLease._get_http_options() ) + request, metadata = self._interceptor.pre_acquire_lease(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseAcquireLease._get_transcoded_request( http_options, request @@ -520,6 +556,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamingServiceClient.AcquireLease", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "AcquireLease", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._AcquireLease._get_response( self._host, @@ -541,7 +604,29 @@ def __call__( pb_resp = streaming_service.Lease.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_acquire_lease(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streaming_service.Lease.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.StreamingServiceClient.acquire_lease", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "AcquireLease", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ReceiveEvents( @@ -556,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]]] = (), ) -> rest_streaming.ResponseIterator: raise NotImplementedError( "Method ReceiveEvents is not available over REST transport" @@ -574,7 +659,7 @@ 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 ReceivePackets is not available over REST transport" @@ -615,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]]] = (), ) -> streaming_service.ReleaseLeaseResponse: r"""Call the release lease method over HTTP. @@ -625,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: ~.streaming_service.ReleaseLeaseResponse: @@ -636,6 +723,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseReleaseLease._get_http_options() ) + request, metadata = self._interceptor.pre_release_lease(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseReleaseLease._get_transcoded_request( http_options, request @@ -650,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.visionai_v1alpha1.StreamingServiceClient.ReleaseLease", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "ReleaseLease", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._ReleaseLease._get_response( self._host, @@ -671,7 +786,31 @@ def __call__( pb_resp = streaming_service.ReleaseLeaseResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_release_lease(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streaming_service.ReleaseLeaseResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.StreamingServiceClient.release_lease", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "ReleaseLease", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RenewLease( @@ -709,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]]] = (), ) -> streaming_service.Lease: r"""Call the renew lease method over HTTP. @@ -719,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: ~.streaming_service.Lease: @@ -730,6 +871,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseRenewLease._get_http_options() ) + request, metadata = self._interceptor.pre_renew_lease(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseRenewLease._get_transcoded_request( http_options, request @@ -744,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.visionai_v1alpha1.StreamingServiceClient.RenewLease", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "RenewLease", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._RenewLease._get_response( self._host, @@ -765,7 +934,29 @@ def __call__( pb_resp = streaming_service.Lease.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 = streaming_service.Lease.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.StreamingServiceClient.renew_lease", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "RenewLease", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SendPackets( @@ -780,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]]] = (), ) -> rest_streaming.ResponseIterator: raise NotImplementedError( "Method SendPackets is not available over REST transport" @@ -882,7 +1073,7 @@ 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. @@ -892,8 +1083,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -902,6 +1095,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -912,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamingServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._GetLocation._get_response( self._host, @@ -931,6 +1152,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.visionai_v1alpha1.StreamingServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -971,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]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -981,8 +1223,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -991,6 +1235,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1001,6 +1246,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamingServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._ListLocations._get_response( self._host, @@ -1020,6 +1292,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.visionai_v1alpha1.StreamingServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1060,7 +1353,7 @@ 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. @@ -1070,8 +1363,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1080,6 +1375,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -1090,6 +1386,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamingServiceClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._GetIamPolicy._get_response( self._host, @@ -1109,6 +1432,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.visionai_v1alpha1.StreamingServiceAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1150,7 +1494,7 @@ 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. @@ -1160,8 +1504,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1170,6 +1516,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -1184,6 +1531,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamingServiceClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._SetIamPolicy._get_response( self._host, @@ -1204,6 +1578,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.visionai_v1alpha1.StreamingServiceAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1246,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]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1256,8 +1651,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1266,6 +1663,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1282,6 +1680,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamingServiceClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._TestIamPermissions._get_response( self._host, @@ -1302,6 +1727,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.visionai_v1alpha1.StreamingServiceAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1344,7 +1790,7 @@ 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. @@ -1354,13 +1800,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 = ( _BaseStreamingServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1377,6 +1826,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamingServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._CancelOperation._get_response( self._host, @@ -1434,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]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -1444,13 +1920,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 = ( _BaseStreamingServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1463,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.visionai_v1alpha1.StreamingServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._DeleteOperation._get_response( self._host, @@ -1518,7 +2024,7 @@ 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. @@ -1528,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: operations_pb2.Operation: Response from GetOperation method. @@ -1538,6 +2046,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1548,6 +2057,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamingServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._GetOperation._get_response( self._host, @@ -1567,6 +2103,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.visionai_v1alpha1.StreamingServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1607,7 +2164,7 @@ 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. @@ -1617,8 +2174,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -1627,6 +2186,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1637,6 +2197,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamingServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._ListOperations._get_response( self._host, @@ -1656,6 +2243,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.visionai_v1alpha1.StreamingServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/async_client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/async_client.py index 469f645d47e3..ae65b1a4a69f 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/async_client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_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, @@ -64,6 +65,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, StreamsServiceTransport from .transports.grpc_asyncio import StreamsServiceGrpcAsyncIOTransport +try: + from google.api_core import client_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 StreamsServiceAsyncClient: """Service describing handlers for resources. @@ -282,6 +292,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.visionai_v1alpha1.StreamsServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "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.visionai.v1alpha1.StreamsService", + "credentialsType": None, + }, + ) + async def list_clusters( self, request: Optional[Union[streams_service.ListClustersRequest, dict]] = None, @@ -289,7 +321,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 Clusters in a given project and location. @@ -334,8 +366,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.visionai_v1alpha1.services.streams_service.pagers.ListClustersAsyncPager: @@ -410,7 +444,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]]] = (), ) -> common.Cluster: r"""Gets details of a single Cluster. @@ -451,8 +485,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.visionai_v1alpha1.types.Cluster: @@ -515,7 +551,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. @@ -574,8 +610,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: @@ -652,7 +690,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 parameters of a single Cluster. @@ -707,8 +745,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: @@ -784,7 +824,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. @@ -829,8 +869,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: @@ -909,7 +951,7 @@ async def list_streams( 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.ListStreamsAsyncPager: r"""Lists Streams in a given project and location. @@ -954,8 +996,10 @@ async def sample_list_streams(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListStreamsAsyncPager: @@ -1030,7 +1074,7 @@ async def get_stream( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Stream: r"""Gets details of a single Stream. @@ -1071,8 +1115,10 @@ async def sample_get_stream(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Stream: @@ -1139,7 +1185,7 @@ async def create_stream( stream_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 Stream in a given project and location. @@ -1197,8 +1243,10 @@ async def sample_create_stream(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1276,7 +1324,7 @@ async def update_stream( 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 Stream. @@ -1331,8 +1379,10 @@ async def sample_update_stream(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1409,7 +1459,7 @@ async def delete_stream( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Stream. @@ -1454,8 +1504,10 @@ async def sample_delete_stream(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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 +1588,7 @@ async def generate_stream_hls_token( stream: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.GenerateStreamHlsTokenResponse: r"""Generate the JWT auth token required to get the stream HLS contents. @@ -1579,8 +1631,10 @@ async def sample_generate_stream_hls_token(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.GenerateStreamHlsTokenResponse: @@ -1641,7 +1695,7 @@ async def list_events( 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.ListEventsAsyncPager: r"""Lists Events in a given project and location. @@ -1686,8 +1740,10 @@ async def sample_list_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.cloud.visionai_v1alpha1.services.streams_service.pagers.ListEventsAsyncPager: @@ -1762,7 +1818,7 @@ async def get_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]]] = (), ) -> streams_resources.Event: r"""Gets details of a single Event. @@ -1803,8 +1859,10 @@ async def sample_get_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.cloud.visionai_v1alpha1.types.Event: @@ -1865,7 +1923,7 @@ async def create_event( event_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 Event in a given project and location. @@ -1923,8 +1981,10 @@ async def sample_create_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.api_core.operation_async.AsyncOperation: @@ -2001,7 +2061,7 @@ async def update_event( 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 Event. @@ -2056,8 +2116,10 @@ async def sample_update_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.api_core.operation_async.AsyncOperation: @@ -2133,7 +2195,7 @@ async def delete_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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Event. @@ -2178,8 +2240,10 @@ async def sample_delete_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.api_core.operation_async.AsyncOperation: @@ -2258,7 +2322,7 @@ async def list_series( 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.ListSeriesAsyncPager: r"""Lists Series in a given project and location. @@ -2303,8 +2367,10 @@ async def sample_list_series(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListSeriesAsyncPager: @@ -2379,7 +2445,7 @@ async def get_series( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Series: r"""Gets details of a single Series. @@ -2420,8 +2486,10 @@ async def sample_get_series(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Series: @@ -2482,7 +2550,7 @@ async def create_series( series_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 Series in a given project and location. @@ -2545,8 +2613,10 @@ async def sample_create_series(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2623,7 +2693,7 @@ async def update_series( 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 Event. @@ -2683,8 +2753,10 @@ async def sample_update_series(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2760,7 +2832,7 @@ async def delete_series( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Series. @@ -2805,8 +2877,10 @@ async def sample_delete_series(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2889,7 +2963,7 @@ async def materialize_channel( channel_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"""Materialize a channel. @@ -2950,8 +3024,10 @@ async def sample_materialize_channel(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3026,7 +3102,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. @@ -3037,8 +3113,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. @@ -3079,7 +3157,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. @@ -3090,8 +3168,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. @@ -3132,7 +3212,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. @@ -3148,8 +3228,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 """ @@ -3186,7 +3268,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. @@ -3201,8 +3283,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 """ @@ -3239,7 +3323,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. @@ -3252,8 +3336,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. @@ -3358,7 +3444,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. @@ -3372,8 +3458,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. @@ -3478,7 +3566,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. @@ -3493,8 +3581,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. @@ -3538,7 +3628,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. @@ -3549,8 +3639,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. @@ -3591,7 +3683,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. @@ -3602,8 +3694,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-visionai/google/cloud/visionai_v1alpha1/services/streams_service/client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/client.py index 6fb97f6dde84..282450c55c96 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_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 @@ -694,6 +704,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( @@ -759,6 +773,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.visionai_v1alpha1.StreamsServiceClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "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.visionai.v1alpha1.StreamsService", + "credentialsType": None, + }, + ) + def list_clusters( self, request: Optional[Union[streams_service.ListClustersRequest, dict]] = None, @@ -766,7 +803,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 Clusters in a given project and location. @@ -811,8 +848,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.visionai_v1alpha1.services.streams_service.pagers.ListClustersPager: @@ -884,7 +923,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]]] = (), ) -> common.Cluster: r"""Gets details of a single Cluster. @@ -925,8 +964,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.visionai_v1alpha1.types.Cluster: @@ -986,7 +1027,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. @@ -1045,8 +1086,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: @@ -1120,7 +1163,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 parameters of a single Cluster. @@ -1175,8 +1218,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: @@ -1249,7 +1294,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. @@ -1294,8 +1339,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: @@ -1371,7 +1418,7 @@ def list_streams( 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.ListStreamsPager: r"""Lists Streams in a given project and location. @@ -1416,8 +1463,10 @@ def sample_list_streams(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListStreamsPager: @@ -1489,7 +1538,7 @@ def get_stream( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Stream: r"""Gets details of a single Stream. @@ -1530,8 +1579,10 @@ def sample_get_stream(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Stream: @@ -1595,7 +1646,7 @@ def create_stream( stream_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 Stream in a given project and location. @@ -1653,8 +1704,10 @@ def sample_create_stream(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1729,7 +1782,7 @@ def update_stream( 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 Stream. @@ -1784,8 +1837,10 @@ def sample_update_stream(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1859,7 +1914,7 @@ def delete_stream( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Stream. @@ -1904,8 +1959,10 @@ def sample_delete_stream(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1983,7 +2040,7 @@ def generate_stream_hls_token( stream: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.GenerateStreamHlsTokenResponse: r"""Generate the JWT auth token required to get the stream HLS contents. @@ -2026,8 +2083,10 @@ def sample_generate_stream_hls_token(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.GenerateStreamHlsTokenResponse: @@ -2087,7 +2146,7 @@ def list_events( 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.ListEventsPager: r"""Lists Events in a given project and location. @@ -2132,8 +2191,10 @@ def sample_list_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.cloud.visionai_v1alpha1.services.streams_service.pagers.ListEventsPager: @@ -2205,7 +2266,7 @@ def get_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]]] = (), ) -> streams_resources.Event: r"""Gets details of a single Event. @@ -2246,8 +2307,10 @@ def sample_get_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.cloud.visionai_v1alpha1.types.Event: @@ -2305,7 +2368,7 @@ def create_event( event_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 Event in a given project and location. @@ -2363,8 +2426,10 @@ def sample_create_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.operation.Operation: @@ -2438,7 +2503,7 @@ def update_event( 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 Event. @@ -2493,8 +2558,10 @@ def sample_update_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.operation.Operation: @@ -2567,7 +2634,7 @@ def delete_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]]] = (), ) -> operation.Operation: r"""Deletes a single Event. @@ -2612,8 +2679,10 @@ def sample_delete_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.operation.Operation: @@ -2689,7 +2758,7 @@ def list_series( 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.ListSeriesPager: r"""Lists Series in a given project and location. @@ -2734,8 +2803,10 @@ def sample_list_series(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListSeriesPager: @@ -2807,7 +2878,7 @@ def get_series( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Series: r"""Gets details of a single Series. @@ -2848,8 +2919,10 @@ def sample_get_series(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Series: @@ -2907,7 +2980,7 @@ def create_series( series_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 Series in a given project and location. @@ -2970,8 +3043,10 @@ def sample_create_series(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3045,7 +3120,7 @@ def update_series( 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 Event. @@ -3105,8 +3180,10 @@ def sample_update_series(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3179,7 +3256,7 @@ def delete_series( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Series. @@ -3224,8 +3301,10 @@ def sample_delete_series(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3305,7 +3384,7 @@ def materialize_channel( channel_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"""Materialize a channel. @@ -3366,8 +3445,10 @@ def sample_materialize_channel(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3452,7 +3533,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. @@ -3463,8 +3544,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. @@ -3505,7 +3588,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. @@ -3516,8 +3599,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. @@ -3558,7 +3643,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. @@ -3574,8 +3659,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 """ @@ -3612,7 +3699,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. @@ -3627,8 +3714,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 """ @@ -3665,7 +3754,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. @@ -3678,8 +3767,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. @@ -3784,7 +3875,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. @@ -3798,8 +3889,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. @@ -3904,7 +3997,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. @@ -3919,8 +4012,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. @@ -3962,7 +4057,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. @@ -3973,8 +4068,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. @@ -4015,7 +4112,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. @@ -4026,8 +4123,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-visionai/google/cloud/visionai_v1alpha1/services/streams_service/pagers.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/pagers.py index c0ab1d98b91c..def302553769 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/pagers.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/pagers.py @@ -71,7 +71,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -85,8 +85,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = streams_service.ListClustersRequest(request) @@ -145,7 +147,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. @@ -159,8 +161,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 = streams_service.ListClustersRequest(request) @@ -223,7 +227,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -237,8 +241,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = streams_service.ListStreamsRequest(request) @@ -297,7 +303,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. @@ -311,8 +317,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 = streams_service.ListStreamsRequest(request) @@ -375,7 +383,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -389,8 +397,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = streams_service.ListEventsRequest(request) @@ -449,7 +459,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. @@ -463,8 +473,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 = streams_service.ListEventsRequest(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 = streams_service.ListSeriesRequest(request) @@ -601,7 +615,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. @@ -615,8 +629,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 = streams_service.ListSeriesRequest(request) diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/transports/grpc.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/transports/grpc.py index bae38d26de2a..d5c734d99926 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/transports/grpc.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_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,7 +27,10 @@ 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.visionai_v1alpha1.types import ( common, @@ -34,6 +40,81 @@ from .base import DEFAULT_CLIENT_INFO, StreamsServiceTransport +try: + from google.api_core import client_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.visionai.v1alpha1.StreamsService", + "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.visionai.v1alpha1.StreamsService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StreamsServiceGrpcTransport(StreamsServiceTransport): """gRPC backend transport for StreamsService. @@ -192,7 +273,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,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 @@ -282,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.visionai.v1alpha1.StreamsService/ListClusters", request_serializer=streams_service.ListClustersRequest.serialize, response_deserializer=streams_service.ListClustersResponse.deserialize, @@ -308,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.visionai.v1alpha1.StreamsService/GetCluster", request_serializer=streams_service.GetClusterRequest.serialize, response_deserializer=common.Cluster.deserialize, @@ -335,7 +423,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.visionai.v1alpha1.StreamsService/CreateCluster", request_serializer=streams_service.CreateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -361,7 +449,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.visionai.v1alpha1.StreamsService/UpdateCluster", request_serializer=streams_service.UpdateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -387,7 +475,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.visionai.v1alpha1.StreamsService/DeleteCluster", request_serializer=streams_service.DeleteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -415,7 +503,7 @@ def list_streams( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_streams" not in self._stubs: - self._stubs["list_streams"] = self.grpc_channel.unary_unary( + self._stubs["list_streams"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/ListStreams", request_serializer=streams_service.ListStreamsRequest.serialize, response_deserializer=streams_service.ListStreamsResponse.deserialize, @@ -441,7 +529,7 @@ def get_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_stream" not in self._stubs: - self._stubs["get_stream"] = self.grpc_channel.unary_unary( + self._stubs["get_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/GetStream", request_serializer=streams_service.GetStreamRequest.serialize, response_deserializer=streams_resources.Stream.deserialize, @@ -467,7 +555,7 @@ def create_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_stream" not in self._stubs: - self._stubs["create_stream"] = self.grpc_channel.unary_unary( + self._stubs["create_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/CreateStream", request_serializer=streams_service.CreateStreamRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -493,7 +581,7 @@ def update_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_stream" not in self._stubs: - self._stubs["update_stream"] = self.grpc_channel.unary_unary( + self._stubs["update_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/UpdateStream", request_serializer=streams_service.UpdateStreamRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -519,7 +607,7 @@ def delete_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_stream" not in self._stubs: - self._stubs["delete_stream"] = self.grpc_channel.unary_unary( + self._stubs["delete_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/DeleteStream", request_serializer=streams_service.DeleteStreamRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -549,7 +637,7 @@ def generate_stream_hls_token( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_stream_hls_token" not in self._stubs: - self._stubs["generate_stream_hls_token"] = self.grpc_channel.unary_unary( + self._stubs["generate_stream_hls_token"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/GenerateStreamHlsToken", request_serializer=streams_service.GenerateStreamHlsTokenRequest.serialize, response_deserializer=streams_service.GenerateStreamHlsTokenResponse.deserialize, @@ -577,7 +665,7 @@ def list_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_events" not in self._stubs: - self._stubs["list_events"] = self.grpc_channel.unary_unary( + self._stubs["list_events"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/ListEvents", request_serializer=streams_service.ListEventsRequest.serialize, response_deserializer=streams_service.ListEventsResponse.deserialize, @@ -603,7 +691,7 @@ def get_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_event" not in self._stubs: - self._stubs["get_event"] = self.grpc_channel.unary_unary( + self._stubs["get_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/GetEvent", request_serializer=streams_service.GetEventRequest.serialize, response_deserializer=streams_resources.Event.deserialize, @@ -629,7 +717,7 @@ def create_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_event" not in self._stubs: - self._stubs["create_event"] = self.grpc_channel.unary_unary( + self._stubs["create_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/CreateEvent", request_serializer=streams_service.CreateEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -655,7 +743,7 @@ def update_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_event" not in self._stubs: - self._stubs["update_event"] = self.grpc_channel.unary_unary( + self._stubs["update_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/UpdateEvent", request_serializer=streams_service.UpdateEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -681,7 +769,7 @@ def delete_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_event" not in self._stubs: - self._stubs["delete_event"] = self.grpc_channel.unary_unary( + self._stubs["delete_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/DeleteEvent", request_serializer=streams_service.DeleteEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -709,7 +797,7 @@ def list_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_series" not in self._stubs: - self._stubs["list_series"] = self.grpc_channel.unary_unary( + self._stubs["list_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/ListSeries", request_serializer=streams_service.ListSeriesRequest.serialize, response_deserializer=streams_service.ListSeriesResponse.deserialize, @@ -735,7 +823,7 @@ def get_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_series" not in self._stubs: - self._stubs["get_series"] = self.grpc_channel.unary_unary( + self._stubs["get_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/GetSeries", request_serializer=streams_service.GetSeriesRequest.serialize, response_deserializer=streams_resources.Series.deserialize, @@ -761,7 +849,7 @@ def create_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_series" not in self._stubs: - self._stubs["create_series"] = self.grpc_channel.unary_unary( + self._stubs["create_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/CreateSeries", request_serializer=streams_service.CreateSeriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -787,7 +875,7 @@ def update_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_series" not in self._stubs: - self._stubs["update_series"] = self.grpc_channel.unary_unary( + self._stubs["update_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/UpdateSeries", request_serializer=streams_service.UpdateSeriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -813,7 +901,7 @@ def delete_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_series" not in self._stubs: - self._stubs["delete_series"] = self.grpc_channel.unary_unary( + self._stubs["delete_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/DeleteSeries", request_serializer=streams_service.DeleteSeriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -841,7 +929,7 @@ def materialize_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "materialize_channel" not in self._stubs: - self._stubs["materialize_channel"] = self.grpc_channel.unary_unary( + self._stubs["materialize_channel"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/MaterializeChannel", request_serializer=streams_service.MaterializeChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -849,7 +937,7 @@ def materialize_channel( return self._stubs["materialize_channel"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -861,7 +949,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, @@ -878,7 +966,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, @@ -895,7 +983,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, @@ -914,7 +1002,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, @@ -933,7 +1021,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, @@ -950,7 +1038,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, @@ -975,7 +1063,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, @@ -1001,7 +1089,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, @@ -1030,7 +1118,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-visionai/google/cloud/visionai_v1alpha1/services/streams_service/transports/grpc_asyncio.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/transports/grpc_asyncio.py index 0de5b218f55c..b9e2433caf30 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_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.visionai_v1alpha1.types import ( common, @@ -38,6 +44,82 @@ from .base import DEFAULT_CLIENT_INFO, StreamsServiceTransport from .grpc import StreamsServiceGrpcTransport +try: + from google.api_core import client_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.visionai.v1alpha1.StreamsService", + "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.visionai.v1alpha1.StreamsService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StreamsServiceGrpcAsyncIOTransport(StreamsServiceTransport): """gRPC AsyncIO backend transport for StreamsService. @@ -239,10 +321,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 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. @@ -293,7 +378,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.visionai.v1alpha1.StreamsService/ListClusters", request_serializer=streams_service.ListClustersRequest.serialize, response_deserializer=streams_service.ListClustersResponse.deserialize, @@ -319,7 +404,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.visionai.v1alpha1.StreamsService/GetCluster", request_serializer=streams_service.GetClusterRequest.serialize, response_deserializer=common.Cluster.deserialize, @@ -348,7 +433,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.visionai.v1alpha1.StreamsService/CreateCluster", request_serializer=streams_service.CreateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -376,7 +461,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.visionai.v1alpha1.StreamsService/UpdateCluster", request_serializer=streams_service.UpdateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -404,7 +489,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.visionai.v1alpha1.StreamsService/DeleteCluster", request_serializer=streams_service.DeleteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -433,7 +518,7 @@ def list_streams( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_streams" not in self._stubs: - self._stubs["list_streams"] = self.grpc_channel.unary_unary( + self._stubs["list_streams"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/ListStreams", request_serializer=streams_service.ListStreamsRequest.serialize, response_deserializer=streams_service.ListStreamsResponse.deserialize, @@ -461,7 +546,7 @@ def get_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_stream" not in self._stubs: - self._stubs["get_stream"] = self.grpc_channel.unary_unary( + self._stubs["get_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/GetStream", request_serializer=streams_service.GetStreamRequest.serialize, response_deserializer=streams_resources.Stream.deserialize, @@ -489,7 +574,7 @@ def create_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_stream" not in self._stubs: - self._stubs["create_stream"] = self.grpc_channel.unary_unary( + self._stubs["create_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/CreateStream", request_serializer=streams_service.CreateStreamRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -517,7 +602,7 @@ def update_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_stream" not in self._stubs: - self._stubs["update_stream"] = self.grpc_channel.unary_unary( + self._stubs["update_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/UpdateStream", request_serializer=streams_service.UpdateStreamRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -545,7 +630,7 @@ def delete_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_stream" not in self._stubs: - self._stubs["delete_stream"] = self.grpc_channel.unary_unary( + self._stubs["delete_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/DeleteStream", request_serializer=streams_service.DeleteStreamRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -575,7 +660,7 @@ def generate_stream_hls_token( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_stream_hls_token" not in self._stubs: - self._stubs["generate_stream_hls_token"] = self.grpc_channel.unary_unary( + self._stubs["generate_stream_hls_token"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/GenerateStreamHlsToken", request_serializer=streams_service.GenerateStreamHlsTokenRequest.serialize, response_deserializer=streams_service.GenerateStreamHlsTokenResponse.deserialize, @@ -604,7 +689,7 @@ def list_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_events" not in self._stubs: - self._stubs["list_events"] = self.grpc_channel.unary_unary( + self._stubs["list_events"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/ListEvents", request_serializer=streams_service.ListEventsRequest.serialize, response_deserializer=streams_service.ListEventsResponse.deserialize, @@ -632,7 +717,7 @@ def get_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_event" not in self._stubs: - self._stubs["get_event"] = self.grpc_channel.unary_unary( + self._stubs["get_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/GetEvent", request_serializer=streams_service.GetEventRequest.serialize, response_deserializer=streams_resources.Event.deserialize, @@ -660,7 +745,7 @@ def create_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_event" not in self._stubs: - self._stubs["create_event"] = self.grpc_channel.unary_unary( + self._stubs["create_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/CreateEvent", request_serializer=streams_service.CreateEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -688,7 +773,7 @@ def update_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_event" not in self._stubs: - self._stubs["update_event"] = self.grpc_channel.unary_unary( + self._stubs["update_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/UpdateEvent", request_serializer=streams_service.UpdateEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -716,7 +801,7 @@ def delete_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_event" not in self._stubs: - self._stubs["delete_event"] = self.grpc_channel.unary_unary( + self._stubs["delete_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/DeleteEvent", request_serializer=streams_service.DeleteEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -745,7 +830,7 @@ def list_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_series" not in self._stubs: - self._stubs["list_series"] = self.grpc_channel.unary_unary( + self._stubs["list_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/ListSeries", request_serializer=streams_service.ListSeriesRequest.serialize, response_deserializer=streams_service.ListSeriesResponse.deserialize, @@ -773,7 +858,7 @@ def get_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_series" not in self._stubs: - self._stubs["get_series"] = self.grpc_channel.unary_unary( + self._stubs["get_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/GetSeries", request_serializer=streams_service.GetSeriesRequest.serialize, response_deserializer=streams_resources.Series.deserialize, @@ -801,7 +886,7 @@ def create_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_series" not in self._stubs: - self._stubs["create_series"] = self.grpc_channel.unary_unary( + self._stubs["create_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/CreateSeries", request_serializer=streams_service.CreateSeriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -829,7 +914,7 @@ def update_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_series" not in self._stubs: - self._stubs["update_series"] = self.grpc_channel.unary_unary( + self._stubs["update_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/UpdateSeries", request_serializer=streams_service.UpdateSeriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -857,7 +942,7 @@ def delete_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_series" not in self._stubs: - self._stubs["delete_series"] = self.grpc_channel.unary_unary( + self._stubs["delete_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/DeleteSeries", request_serializer=streams_service.DeleteSeriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -885,7 +970,7 @@ def materialize_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "materialize_channel" not in self._stubs: - self._stubs["materialize_channel"] = self.grpc_channel.unary_unary( + self._stubs["materialize_channel"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/MaterializeChannel", request_serializer=streams_service.MaterializeChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1058,7 +1143,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: @@ -1074,7 +1159,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, @@ -1091,7 +1176,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, @@ -1108,7 +1193,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, @@ -1127,7 +1212,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, @@ -1146,7 +1231,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, @@ -1163,7 +1248,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, @@ -1188,7 +1273,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, @@ -1214,7 +1299,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, @@ -1243,7 +1328,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-visionai/google/cloud/visionai_v1alpha1/services/streams_service/transports/rest.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/transports/rest.py index ae70720f44ab..460b0d633a66 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/transports/rest.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_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 @@ -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, @@ -253,8 +261,10 @@ def post_update_stream(self, response): def pre_create_cluster( self, request: streams_service.CreateClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.CreateClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.CreateClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_cluster Override in a subclass to manipulate the request or metadata @@ -276,8 +286,10 @@ def post_create_cluster( def pre_create_event( self, request: streams_service.CreateEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.CreateEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.CreateEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_event Override in a subclass to manipulate the request or metadata @@ -299,8 +311,10 @@ def post_create_event( def pre_create_series( self, request: streams_service.CreateSeriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.CreateSeriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.CreateSeriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_series Override in a subclass to manipulate the request or metadata @@ -322,8 +336,10 @@ def post_create_series( def pre_create_stream( self, request: streams_service.CreateStreamRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.CreateStreamRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.CreateStreamRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_stream Override in a subclass to manipulate the request or metadata @@ -345,8 +361,10 @@ def post_create_stream( def pre_delete_cluster( self, request: streams_service.DeleteClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.DeleteClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.DeleteClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_cluster Override in a subclass to manipulate the request or metadata @@ -368,8 +386,10 @@ def post_delete_cluster( def pre_delete_event( self, request: streams_service.DeleteEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.DeleteEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.DeleteEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_event Override in a subclass to manipulate the request or metadata @@ -391,8 +411,10 @@ def post_delete_event( def pre_delete_series( self, request: streams_service.DeleteSeriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.DeleteSeriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.DeleteSeriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_series Override in a subclass to manipulate the request or metadata @@ -414,8 +436,10 @@ def post_delete_series( def pre_delete_stream( self, request: streams_service.DeleteStreamRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.DeleteStreamRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.DeleteStreamRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_stream Override in a subclass to manipulate the request or metadata @@ -437,9 +461,10 @@ def post_delete_stream( def pre_generate_stream_hls_token( self, request: streams_service.GenerateStreamHlsTokenRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - streams_service.GenerateStreamHlsTokenRequest, Sequence[Tuple[str, str]] + streams_service.GenerateStreamHlsTokenRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for generate_stream_hls_token @@ -462,8 +487,10 @@ def post_generate_stream_hls_token( def pre_get_cluster( self, request: streams_service.GetClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.GetClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.GetClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_cluster Override in a subclass to manipulate the request or metadata @@ -483,8 +510,10 @@ def post_get_cluster(self, response: common.Cluster) -> common.Cluster: def pre_get_event( self, request: streams_service.GetEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.GetEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.GetEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_event Override in a subclass to manipulate the request or metadata @@ -506,8 +535,10 @@ def post_get_event( def pre_get_series( self, request: streams_service.GetSeriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.GetSeriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.GetSeriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_series Override in a subclass to manipulate the request or metadata @@ -529,8 +560,10 @@ def post_get_series( def pre_get_stream( self, request: streams_service.GetStreamRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.GetStreamRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.GetStreamRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_stream Override in a subclass to manipulate the request or metadata @@ -552,8 +585,10 @@ def post_get_stream( def pre_list_clusters( self, request: streams_service.ListClustersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.ListClustersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.ListClustersRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_clusters Override in a subclass to manipulate the request or metadata @@ -575,8 +610,10 @@ def post_list_clusters( def pre_list_events( self, request: streams_service.ListEventsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.ListEventsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.ListEventsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_events Override in a subclass to manipulate the request or metadata @@ -598,8 +635,10 @@ def post_list_events( def pre_list_series( self, request: streams_service.ListSeriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.ListSeriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.ListSeriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_series Override in a subclass to manipulate the request or metadata @@ -621,8 +660,10 @@ def post_list_series( def pre_list_streams( self, request: streams_service.ListStreamsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.ListStreamsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.ListStreamsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_streams Override in a subclass to manipulate the request or metadata @@ -644,8 +685,11 @@ def post_list_streams( def pre_materialize_channel( self, request: streams_service.MaterializeChannelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.MaterializeChannelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.MaterializeChannelRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for materialize_channel Override in a subclass to manipulate the request or metadata @@ -667,8 +711,10 @@ def post_materialize_channel( def pre_update_cluster( self, request: streams_service.UpdateClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.UpdateClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.UpdateClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_cluster Override in a subclass to manipulate the request or metadata @@ -690,8 +736,10 @@ def post_update_cluster( def pre_update_event( self, request: streams_service.UpdateEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.UpdateEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.UpdateEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_event Override in a subclass to manipulate the request or metadata @@ -713,8 +761,10 @@ def post_update_event( def pre_update_series( self, request: streams_service.UpdateSeriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.UpdateSeriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.UpdateSeriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_series Override in a subclass to manipulate the request or metadata @@ -736,8 +786,10 @@ def post_update_series( def pre_update_stream( self, request: streams_service.UpdateStreamRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.UpdateStreamRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.UpdateStreamRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_stream Override in a subclass to manipulate the request or metadata @@ -759,8 +811,10 @@ def post_update_stream( 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 @@ -782,8 +836,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 @@ -805,8 +861,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 @@ -826,8 +884,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 @@ -847,8 +907,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 @@ -870,8 +933,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 @@ -891,8 +956,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 @@ -912,8 +979,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 @@ -935,8 +1004,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 @@ -1143,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create cluster method over HTTP. @@ -1153,8 +1224,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1167,6 +1240,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseCreateCluster._get_http_options() ) + request, metadata = self._interceptor.pre_create_cluster(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseCreateCluster._get_transcoded_request( http_options, request @@ -1181,6 +1255,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.CreateCluster", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "CreateCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._CreateCluster._get_response( self._host, @@ -1200,7 +1301,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.visionai_v1alpha1.StreamsServiceClient.create_cluster", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "CreateCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateEvent( @@ -1238,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create event method over HTTP. @@ -1248,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: ~.operations_pb2.Operation: @@ -1262,6 +1387,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseCreateEvent._get_http_options() ) + request, metadata = self._interceptor.pre_create_event(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseCreateEvent._get_transcoded_request( http_options, request @@ -1276,6 +1402,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.CreateEvent", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "CreateEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._CreateEvent._get_response( self._host, @@ -1295,7 +1448,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_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.StreamsServiceClient.create_event", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "CreateEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSeries( @@ -1333,7 +1508,7 @@ 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 series method over HTTP. @@ -1343,8 +1518,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1357,6 +1534,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseCreateSeries._get_http_options() ) + request, metadata = self._interceptor.pre_create_series(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseCreateSeries._get_transcoded_request( http_options, request @@ -1371,6 +1549,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.CreateSeries", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "CreateSeries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._CreateSeries._get_response( self._host, @@ -1390,7 +1595,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_series(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.StreamsServiceClient.create_series", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "CreateSeries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateStream( @@ -1428,7 +1655,7 @@ 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 stream method over HTTP. @@ -1438,8 +1665,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1452,6 +1681,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseCreateStream._get_http_options() ) + request, metadata = self._interceptor.pre_create_stream(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseCreateStream._get_transcoded_request( http_options, request @@ -1466,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.CreateStream", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "CreateStream", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._CreateStream._get_response( self._host, @@ -1485,7 +1742,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_stream(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.StreamsServiceClient.create_stream", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "CreateStream", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCluster( @@ -1522,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 delete cluster method over HTTP. @@ -1532,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: @@ -1546,6 +1827,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseDeleteCluster._get_http_options() ) + request, metadata = self._interceptor.pre_delete_cluster(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseDeleteCluster._get_transcoded_request( http_options, request @@ -1556,6 +1838,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.DeleteCluster", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "DeleteCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._DeleteCluster._get_response( self._host, @@ -1574,7 +1883,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.visionai_v1alpha1.StreamsServiceClient.delete_cluster", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "DeleteCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteEvent( @@ -1611,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.Operation: r"""Call the delete event method over HTTP. @@ -1621,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.Operation: @@ -1635,6 +1968,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseDeleteEvent._get_http_options() ) + request, metadata = self._interceptor.pre_delete_event(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseDeleteEvent._get_transcoded_request( http_options, request @@ -1645,6 +1979,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.DeleteEvent", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "DeleteEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._DeleteEvent._get_response( self._host, @@ -1663,7 +2024,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_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.StreamsServiceClient.delete_event", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "DeleteEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteSeries( @@ -1700,7 +2083,7 @@ 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 series method over HTTP. @@ -1710,8 +2093,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1724,6 +2109,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseDeleteSeries._get_http_options() ) + request, metadata = self._interceptor.pre_delete_series(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseDeleteSeries._get_transcoded_request( http_options, request @@ -1734,6 +2120,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.DeleteSeries", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "DeleteSeries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._DeleteSeries._get_response( self._host, @@ -1752,7 +2165,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_series(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.StreamsServiceClient.delete_series", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "DeleteSeries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteStream( @@ -1789,7 +2224,7 @@ 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 stream method over HTTP. @@ -1799,8 +2234,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1813,6 +2250,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseDeleteStream._get_http_options() ) + request, metadata = self._interceptor.pre_delete_stream(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseDeleteStream._get_transcoded_request( http_options, request @@ -1823,6 +2261,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.DeleteStream", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "DeleteStream", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._DeleteStream._get_response( self._host, @@ -1841,7 +2306,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_stream(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.StreamsServiceClient.delete_stream", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "DeleteStream", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateStreamHlsToken( @@ -1880,7 +2367,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.GenerateStreamHlsTokenResponse: r"""Call the generate stream hls token method over HTTP. @@ -1891,8 +2378,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.streams_service.GenerateStreamHlsTokenResponse: @@ -1904,6 +2393,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGenerateStreamHlsToken._get_http_options() ) + request, metadata = self._interceptor.pre_generate_stream_hls_token( request, metadata ) @@ -1920,6 +2410,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.GenerateStreamHlsToken", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GenerateStreamHlsToken", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( StreamsServiceRestTransport._GenerateStreamHlsToken._get_response( @@ -1943,7 +2460,31 @@ def __call__( pb_resp = streams_service.GenerateStreamHlsTokenResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_stream_hls_token(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + streams_service.GenerateStreamHlsTokenResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.StreamsServiceClient.generate_stream_hls_token", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GenerateStreamHlsToken", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCluster( @@ -1980,7 +2521,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.Cluster: r"""Call the get cluster method over HTTP. @@ -1990,8 +2531,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.common.Cluster: @@ -2003,6 +2546,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetCluster._get_http_options() ) + request, metadata = self._interceptor.pre_get_cluster(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseGetCluster._get_transcoded_request( http_options, request @@ -2015,6 +2559,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.GetCluster", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetCluster._get_response( self._host, @@ -2035,7 +2606,29 @@ def __call__( pb_resp = common.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 = common.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.visionai_v1alpha1.StreamsServiceClient.get_cluster", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEvent( @@ -2072,7 +2665,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Event: r"""Call the get event method over HTTP. @@ -2082,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: ~.streams_resources.Event: @@ -2093,6 +2688,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetEvent._get_http_options() ) + request, metadata = self._interceptor.pre_get_event(request, metadata) transcoded_request = ( _BaseStreamsServiceRestTransport._BaseGetEvent._get_transcoded_request( @@ -2107,6 +2703,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.GetEvent", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetEvent._get_response( self._host, @@ -2127,7 +2750,29 @@ def __call__( pb_resp = streams_resources.Event.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_resources.Event.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.StreamsServiceClient.get_event", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSeries( @@ -2164,7 +2809,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Series: r"""Call the get series method over HTTP. @@ -2174,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: ~.streams_resources.Series: @@ -2185,6 +2832,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetSeries._get_http_options() ) + request, metadata = self._interceptor.pre_get_series(request, metadata) transcoded_request = ( _BaseStreamsServiceRestTransport._BaseGetSeries._get_transcoded_request( @@ -2199,6 +2847,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.GetSeries", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetSeries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetSeries._get_response( self._host, @@ -2219,7 +2894,29 @@ def __call__( pb_resp = streams_resources.Series.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_series(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_resources.Series.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.StreamsServiceClient.get_series", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetSeries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetStream( @@ -2256,7 +2953,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Stream: r"""Call the get stream method over HTTP. @@ -2266,8 +2963,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.streams_resources.Stream: @@ -2283,6 +2982,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetStream._get_http_options() ) + request, metadata = self._interceptor.pre_get_stream(request, metadata) transcoded_request = ( _BaseStreamsServiceRestTransport._BaseGetStream._get_transcoded_request( @@ -2297,6 +2997,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.GetStream", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetStream", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetStream._get_response( self._host, @@ -2317,7 +3044,29 @@ def __call__( pb_resp = streams_resources.Stream.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_stream(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_resources.Stream.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.StreamsServiceClient.get_stream", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetStream", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListClusters( @@ -2354,7 +3103,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.ListClustersResponse: r"""Call the list clusters method over HTTP. @@ -2365,8 +3114,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.streams_service.ListClustersResponse: @@ -2378,6 +3129,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseListClusters._get_http_options() ) + request, metadata = self._interceptor.pre_list_clusters(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseListClusters._get_transcoded_request( http_options, request @@ -2388,6 +3140,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.ListClusters", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "ListClusters", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._ListClusters._get_response( self._host, @@ -2408,7 +3187,31 @@ def __call__( pb_resp = streams_service.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 = streams_service.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.visionai_v1alpha1.StreamsServiceClient.list_clusters", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "ListClusters", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEvents( @@ -2445,7 +3248,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.ListEventsResponse: r"""Call the list events method over HTTP. @@ -2456,8 +3259,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.streams_service.ListEventsResponse: @@ -2469,6 +3274,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseListEvents._get_http_options() ) + request, metadata = self._interceptor.pre_list_events(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseListEvents._get_transcoded_request( http_options, request @@ -2481,6 +3287,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.ListEvents", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "ListEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._ListEvents._get_response( self._host, @@ -2501,7 +3334,31 @@ def __call__( pb_resp = streams_service.ListEventsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_events(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_service.ListEventsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.StreamsServiceClient.list_events", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "ListEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSeries( @@ -2538,7 +3395,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.ListSeriesResponse: r"""Call the list series method over HTTP. @@ -2549,8 +3406,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.streams_service.ListSeriesResponse: @@ -2562,6 +3421,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseListSeries._get_http_options() ) + request, metadata = self._interceptor.pre_list_series(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseListSeries._get_transcoded_request( http_options, request @@ -2574,6 +3434,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.ListSeries", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "ListSeries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._ListSeries._get_response( self._host, @@ -2594,7 +3481,31 @@ def __call__( pb_resp = streams_service.ListSeriesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_series(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_service.ListSeriesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.StreamsServiceClient.list_series", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "ListSeries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListStreams( @@ -2631,7 +3542,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.ListStreamsResponse: r"""Call the list streams method over HTTP. @@ -2642,8 +3553,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.streams_service.ListStreamsResponse: @@ -2655,6 +3568,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseListStreams._get_http_options() ) + request, metadata = self._interceptor.pre_list_streams(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseListStreams._get_transcoded_request( http_options, request @@ -2665,6 +3579,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.ListStreams", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "ListStreams", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._ListStreams._get_response( self._host, @@ -2685,7 +3626,31 @@ def __call__( pb_resp = streams_service.ListStreamsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_streams(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_service.ListStreamsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.StreamsServiceClient.list_streams", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "ListStreams", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _MaterializeChannel( @@ -2723,7 +3688,7 @@ 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 materialize channel method over HTTP. @@ -2733,8 +3698,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2747,6 +3714,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseMaterializeChannel._get_http_options() ) + request, metadata = self._interceptor.pre_materialize_channel( request, metadata ) @@ -2763,6 +3731,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.MaterializeChannel", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "MaterializeChannel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._MaterializeChannel._get_response( self._host, @@ -2782,7 +3777,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_materialize_channel(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.StreamsServiceClient.materialize_channel", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "MaterializeChannel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCluster( @@ -2820,7 +3837,7 @@ 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. @@ -2830,8 +3847,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2844,6 +3863,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseUpdateCluster._get_http_options() ) + request, metadata = self._interceptor.pre_update_cluster(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseUpdateCluster._get_transcoded_request( http_options, request @@ -2858,6 +3878,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.UpdateCluster", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "UpdateCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._UpdateCluster._get_response( self._host, @@ -2877,7 +3924,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.visionai_v1alpha1.StreamsServiceClient.update_cluster", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "UpdateCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateEvent( @@ -2915,7 +3984,7 @@ 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 event method over HTTP. @@ -2925,8 +3994,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2939,6 +4010,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseUpdateEvent._get_http_options() ) + request, metadata = self._interceptor.pre_update_event(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseUpdateEvent._get_transcoded_request( http_options, request @@ -2953,6 +4025,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.UpdateEvent", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "UpdateEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._UpdateEvent._get_response( self._host, @@ -2972,7 +4071,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_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.StreamsServiceClient.update_event", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "UpdateEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSeries( @@ -3010,7 +4131,7 @@ 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 series method over HTTP. @@ -3020,8 +4141,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3034,6 +4157,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseUpdateSeries._get_http_options() ) + request, metadata = self._interceptor.pre_update_series(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseUpdateSeries._get_transcoded_request( http_options, request @@ -3048,6 +4172,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.UpdateSeries", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "UpdateSeries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._UpdateSeries._get_response( self._host, @@ -3067,7 +4218,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_series(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.StreamsServiceClient.update_series", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "UpdateSeries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateStream( @@ -3105,7 +4278,7 @@ 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 stream method over HTTP. @@ -3115,8 +4288,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3129,6 +4304,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseUpdateStream._get_http_options() ) + request, metadata = self._interceptor.pre_update_stream(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseUpdateStream._get_transcoded_request( http_options, request @@ -3143,6 +4319,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.UpdateStream", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "UpdateStream", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._UpdateStream._get_response( self._host, @@ -3162,7 +4365,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_stream(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.StreamsServiceClient.update_stream", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "UpdateStream", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -3392,7 +4617,7 @@ 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. @@ -3402,8 +4627,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -3412,6 +4639,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -3422,6 +4650,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetLocation._get_response( self._host, @@ -3441,6 +4696,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.visionai_v1alpha1.StreamsServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3481,7 +4757,7 @@ 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. @@ -3491,8 +4767,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -3501,6 +4779,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -3511,6 +4790,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._ListLocations._get_response( self._host, @@ -3530,6 +4836,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.visionai_v1alpha1.StreamsServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3570,7 +4897,7 @@ 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. @@ -3580,8 +4907,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -3590,6 +4919,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -3600,6 +4930,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetIamPolicy._get_response( self._host, @@ -3619,6 +4976,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.visionai_v1alpha1.StreamsServiceAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3660,7 +5038,7 @@ 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. @@ -3670,8 +5048,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -3680,6 +5060,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -3694,6 +5075,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._SetIamPolicy._get_response( self._host, @@ -3714,6 +5122,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.visionai_v1alpha1.StreamsServiceAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3755,7 +5184,7 @@ 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. @@ -3765,8 +5194,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -3775,6 +5206,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -3791,6 +5223,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._TestIamPermissions._get_response( self._host, @@ -3811,6 +5270,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.visionai_v1alpha1.StreamsServiceAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3852,7 +5332,7 @@ 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. @@ -3862,13 +5342,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 = ( _BaseStreamsServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -3885,6 +5368,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._CancelOperation._get_response( self._host, @@ -3941,7 +5451,7 @@ 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. @@ -3951,13 +5461,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 = ( _BaseStreamsServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -3970,6 +5483,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._DeleteOperation._get_response( self._host, @@ -4025,7 +5565,7 @@ 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. @@ -4035,8 +5575,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -4045,6 +5587,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -4055,6 +5598,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetOperation._get_response( self._host, @@ -4074,6 +5644,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.visionai_v1alpha1.StreamsServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4114,7 +5705,7 @@ 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. @@ -4124,8 +5715,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -4134,6 +5727,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -4144,6 +5738,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.StreamsServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._ListOperations._get_response( self._host, @@ -4163,6 +5784,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.visionai_v1alpha1.StreamsServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/async_client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/async_client.py index e10cfafa89bd..55d6da6c15aa 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/async_client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/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, @@ -62,6 +63,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, WarehouseTransport from .transports.grpc_asyncio import WarehouseGrpcAsyncIOTransport +try: + from google.api_core import client_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 WarehouseAsyncClient: """Service that manages media content + metadata for streaming.""" @@ -269,6 +279,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.visionai_v1alpha1.WarehouseAsyncClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "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.visionai.v1alpha1.Warehouse", + "credentialsType": None, + }, + ) + async def create_asset( self, request: Optional[Union[warehouse.CreateAssetRequest, dict]] = None, @@ -278,7 +310,7 @@ async def create_asset( asset_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]]] = (), ) -> warehouse.Asset: r"""Creates an asset inside corpus. @@ -340,8 +372,10 @@ async def sample_create_asset(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Asset: @@ -412,7 +446,7 @@ async def update_asset( 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]]] = (), ) -> warehouse.Asset: r"""Updates an asset inside corpus. @@ -462,8 +496,10 @@ async def sample_update_asset(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Asset: @@ -533,7 +569,7 @@ async def get_asset( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Reads an asset inside corpus. @@ -576,8 +612,10 @@ async def sample_get_asset(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Asset: @@ -643,7 +681,7 @@ async def list_assets( 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.ListAssetsAsyncPager: r"""Lists an list of assets inside corpus. @@ -688,8 +726,10 @@ async def sample_list_assets(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListAssetsAsyncPager: @@ -764,7 +804,7 @@ async def delete_asset( name: Optional[str] = None, retry: OptionalRetry = gapic_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 asset inside corpus. @@ -811,8 +851,10 @@ async def sample_delete_asset(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -892,7 +934,7 @@ async def create_corpus( corpus: Optional[warehouse.Corpus] = None, retry: OptionalRetry = gapic_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 corpus inside a project. @@ -948,8 +990,10 @@ async def sample_create_corpus(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1023,7 +1067,7 @@ async def get_corpus( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Corpus: r"""Gets corpus details inside a project. @@ -1066,8 +1110,10 @@ async def sample_get_corpus(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Corpus: @@ -1131,7 +1177,7 @@ async def update_corpus( 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]]] = (), ) -> warehouse.Corpus: r"""Updates a corpus in a project. @@ -1182,8 +1228,10 @@ async def sample_update_corpus(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Corpus: @@ -1250,7 +1298,7 @@ async def list_corpora( 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.ListCorporaAsyncPager: r"""Lists all corpora in a project. @@ -1294,8 +1342,10 @@ async def sample_list_corpora(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListCorporaAsyncPager: @@ -1370,7 +1420,7 @@ async def delete_corpus( name: Optional[str] = None, retry: OptionalRetry = 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 corpus only if its empty. Returns empty response. @@ -1411,8 +1461,10 @@ async def sample_delete_corpus(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -1465,7 +1517,7 @@ async def create_data_schema( data_schema: Optional[warehouse.DataSchema] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Creates data schema inside corpus. @@ -1518,8 +1570,10 @@ async def sample_create_data_schema(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.DataSchema: @@ -1584,7 +1638,7 @@ async def update_data_schema( 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]]] = (), ) -> warehouse.DataSchema: r"""Updates data schema inside corpus. @@ -1636,8 +1690,10 @@ async def sample_update_data_schema(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.DataSchema: @@ -1703,7 +1759,7 @@ async def get_data_schema( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Gets data schema inside corpus. @@ -1747,8 +1803,10 @@ async def sample_get_data_schema(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.DataSchema: @@ -1810,7 +1868,7 @@ async def delete_data_schema( name: Optional[str] = None, retry: OptionalRetry = 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 data schema inside corpus. @@ -1850,8 +1908,10 @@ async def sample_delete_data_schema(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -1903,7 +1963,7 @@ async def list_data_schemas( 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.ListDataSchemasAsyncPager: r"""Lists a list of data schemas inside corpus. @@ -1948,8 +2008,10 @@ async def sample_list_data_schemas(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListDataSchemasAsyncPager: @@ -2026,7 +2088,7 @@ async def create_annotation( annotation_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]]] = (), ) -> warehouse.Annotation: r"""Creates annotation inside asset. @@ -2088,8 +2150,10 @@ async def sample_create_annotation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Annotation: @@ -2155,7 +2219,7 @@ async def get_annotation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Reads annotation inside asset. @@ -2200,8 +2264,10 @@ async def sample_get_annotation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Annotation: @@ -2263,7 +2329,7 @@ async def list_annotations( 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.ListAnnotationsAsyncPager: r"""Lists a list of annotations inside asset. @@ -2308,8 +2374,10 @@ async def sample_list_annotations(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListAnnotationsAsyncPager: @@ -2385,7 +2453,7 @@ async def update_annotation( 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]]] = (), ) -> warehouse.Annotation: r"""Updates annotation inside asset. @@ -2435,8 +2503,10 @@ async def sample_update_annotation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Annotation: @@ -2502,7 +2572,7 @@ async def delete_annotation( name: Optional[str] = None, retry: OptionalRetry = 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 annotation inside asset. @@ -2543,8 +2613,10 @@ async def sample_delete_annotation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -2595,7 +2667,7 @@ def ingest_asset( *, retry: OptionalRetry = 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[warehouse.IngestAssetResponse]]: r"""Ingests data for the asset. It is not allowed to ingest a data chunk which is already expired according @@ -2649,8 +2721,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.visionai_v1alpha1.types.IngestAssetResponse]: @@ -2683,7 +2757,7 @@ async def clip_asset( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ClipAssetResponse: r"""Generates clips for downloading. The api takes in a time range, and generates a clip of the first content available after @@ -2723,8 +2797,10 @@ async def sample_clip_asset(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.ClipAssetResponse: @@ -2768,7 +2844,7 @@ async def generate_hls_uri( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.GenerateHlsUriResponse: r"""Generates a uri for an HLS manifest. The api takes in a collection of time ranges, and generates a URI for an @@ -2807,8 +2883,10 @@ async def sample_generate_hls_uri(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.GenerateHlsUriResponse: @@ -2857,7 +2935,7 @@ async def create_search_config( search_config_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]]] = (), ) -> warehouse.SearchConfig: r"""Creates a search configuration inside a corpus. @@ -2936,8 +3014,10 @@ async def sample_create_search_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.cloud.visionai_v1alpha1.types.SearchConfig: @@ -3004,7 +3084,7 @@ async def update_search_config( 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]]] = (), ) -> warehouse.SearchConfig: r"""Updates a search configuration inside a corpus. @@ -3072,8 +3152,10 @@ async def sample_update_search_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.cloud.visionai_v1alpha1.types.SearchConfig: @@ -3139,7 +3221,7 @@ async def get_search_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Gets a search configuration inside a corpus. @@ -3183,8 +3265,10 @@ async def sample_get_search_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.cloud.visionai_v1alpha1.types.SearchConfig: @@ -3246,7 +3330,7 @@ async def delete_search_config( name: Optional[str] = None, retry: OptionalRetry = 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 search configuration inside a corpus. @@ -3291,8 +3375,10 @@ async def sample_delete_search_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3344,7 +3430,7 @@ async def list_search_configs( 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.ListSearchConfigsAsyncPager: r"""Lists all search configurations inside a corpus. @@ -3390,8 +3476,10 @@ async def sample_list_search_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.visionai_v1alpha1.services.warehouse.pagers.ListSearchConfigsAsyncPager: @@ -3465,7 +3553,7 @@ async def search_assets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchAssetsAsyncPager: r"""Search media asset. @@ -3502,8 +3590,10 @@ async def sample_search_assets(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.services.warehouse.pagers.SearchAssetsAsyncPager: @@ -3563,7 +3653,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. @@ -3574,8 +3664,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. @@ -3616,7 +3708,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. @@ -3627,8 +3719,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. @@ -3669,7 +3763,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. @@ -3685,8 +3779,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 """ @@ -3723,7 +3819,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. @@ -3738,8 +3834,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 """ @@ -3776,7 +3874,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. @@ -3789,8 +3887,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. @@ -3895,7 +3995,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. @@ -3909,8 +4009,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. @@ -4015,7 +4117,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. @@ -4030,8 +4132,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. @@ -4075,7 +4179,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. @@ -4086,8 +4190,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. @@ -4128,7 +4234,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. @@ -4139,8 +4245,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-visionai/google/cloud/visionai_v1alpha1/services/warehouse/client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/client.py index 7555baa994df..86ac74731ecd 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/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.cloud.location import locations_pb2 # type: ignore @@ -686,6 +696,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( @@ -748,6 +762,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.visionai_v1alpha1.WarehouseClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "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.visionai.v1alpha1.Warehouse", + "credentialsType": None, + }, + ) + def create_asset( self, request: Optional[Union[warehouse.CreateAssetRequest, dict]] = None, @@ -757,7 +794,7 @@ def create_asset( asset_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]]] = (), ) -> warehouse.Asset: r"""Creates an asset inside corpus. @@ -819,8 +856,10 @@ def sample_create_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Asset: @@ -888,7 +927,7 @@ def update_asset( 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]]] = (), ) -> warehouse.Asset: r"""Updates an asset inside corpus. @@ -938,8 +977,10 @@ def sample_update_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Asset: @@ -1006,7 +1047,7 @@ def get_asset( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Reads an asset inside corpus. @@ -1049,8 +1090,10 @@ def sample_get_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Asset: @@ -1113,7 +1156,7 @@ def list_assets( 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.ListAssetsPager: r"""Lists an list of assets inside corpus. @@ -1158,8 +1201,10 @@ def sample_list_assets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListAssetsPager: @@ -1231,7 +1276,7 @@ def delete_asset( name: Optional[str] = None, retry: OptionalRetry = gapic_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 asset inside corpus. @@ -1278,8 +1323,10 @@ def sample_delete_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1356,7 +1403,7 @@ def create_corpus( corpus: Optional[warehouse.Corpus] = None, retry: OptionalRetry = gapic_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 corpus inside a project. @@ -1412,8 +1459,10 @@ def sample_create_corpus(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1484,7 +1533,7 @@ def get_corpus( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Corpus: r"""Gets corpus details inside a project. @@ -1527,8 +1576,10 @@ def sample_get_corpus(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Corpus: @@ -1589,7 +1640,7 @@ def update_corpus( 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]]] = (), ) -> warehouse.Corpus: r"""Updates a corpus in a project. @@ -1640,8 +1691,10 @@ def sample_update_corpus(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Corpus: @@ -1705,7 +1758,7 @@ def list_corpora( 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.ListCorporaPager: r"""Lists all corpora in a project. @@ -1749,8 +1802,10 @@ def sample_list_corpora(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListCorporaPager: @@ -1822,7 +1877,7 @@ def delete_corpus( name: Optional[str] = None, retry: OptionalRetry = 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 corpus only if its empty. Returns empty response. @@ -1863,8 +1918,10 @@ def sample_delete_corpus(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -1914,7 +1971,7 @@ def create_data_schema( data_schema: Optional[warehouse.DataSchema] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Creates data schema inside corpus. @@ -1967,8 +2024,10 @@ def sample_create_data_schema(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.DataSchema: @@ -2030,7 +2089,7 @@ def update_data_schema( 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]]] = (), ) -> warehouse.DataSchema: r"""Updates data schema inside corpus. @@ -2082,8 +2141,10 @@ def sample_update_data_schema(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.DataSchema: @@ -2146,7 +2207,7 @@ def get_data_schema( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Gets data schema inside corpus. @@ -2190,8 +2251,10 @@ def sample_get_data_schema(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.DataSchema: @@ -2250,7 +2313,7 @@ def delete_data_schema( name: Optional[str] = None, retry: OptionalRetry = 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 data schema inside corpus. @@ -2290,8 +2353,10 @@ def sample_delete_data_schema(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -2340,7 +2405,7 @@ def list_data_schemas( 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.ListDataSchemasPager: r"""Lists a list of data schemas inside corpus. @@ -2385,8 +2450,10 @@ def sample_list_data_schemas(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListDataSchemasPager: @@ -2460,7 +2527,7 @@ def create_annotation( annotation_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]]] = (), ) -> warehouse.Annotation: r"""Creates annotation inside asset. @@ -2522,8 +2589,10 @@ def sample_create_annotation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Annotation: @@ -2586,7 +2655,7 @@ def get_annotation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Reads annotation inside asset. @@ -2631,8 +2700,10 @@ def sample_get_annotation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Annotation: @@ -2691,7 +2762,7 @@ def list_annotations( 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.ListAnnotationsPager: r"""Lists a list of annotations inside asset. @@ -2736,8 +2807,10 @@ def sample_list_annotations(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListAnnotationsPager: @@ -2810,7 +2883,7 @@ def update_annotation( 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]]] = (), ) -> warehouse.Annotation: r"""Updates annotation inside asset. @@ -2860,8 +2933,10 @@ def sample_update_annotation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.Annotation: @@ -2924,7 +2999,7 @@ def delete_annotation( name: Optional[str] = None, retry: OptionalRetry = 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 annotation inside asset. @@ -2965,8 +3040,10 @@ def sample_delete_annotation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -3014,7 +3091,7 @@ def ingest_asset( *, retry: OptionalRetry = 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[warehouse.IngestAssetResponse]: r"""Ingests data for the asset. It is not allowed to ingest a data chunk which is already expired according @@ -3068,8 +3145,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.visionai_v1alpha1.types.IngestAssetResponse]: @@ -3100,7 +3179,7 @@ def clip_asset( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ClipAssetResponse: r"""Generates clips for downloading. The api takes in a time range, and generates a clip of the first content available after @@ -3140,8 +3219,10 @@ def sample_clip_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.ClipAssetResponse: @@ -3183,7 +3264,7 @@ def generate_hls_uri( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.GenerateHlsUriResponse: r"""Generates a uri for an HLS manifest. The api takes in a collection of time ranges, and generates a URI for an @@ -3222,8 +3303,10 @@ def sample_generate_hls_uri(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.types.GenerateHlsUriResponse: @@ -3270,7 +3353,7 @@ def create_search_config( search_config_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]]] = (), ) -> warehouse.SearchConfig: r"""Creates a search configuration inside a corpus. @@ -3349,8 +3432,10 @@ def sample_create_search_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.visionai_v1alpha1.types.SearchConfig: @@ -3414,7 +3499,7 @@ def update_search_config( 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]]] = (), ) -> warehouse.SearchConfig: r"""Updates a search configuration inside a corpus. @@ -3482,8 +3567,10 @@ def sample_update_search_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.visionai_v1alpha1.types.SearchConfig: @@ -3546,7 +3633,7 @@ def get_search_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Gets a search configuration inside a corpus. @@ -3590,8 +3677,10 @@ def sample_get_search_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.visionai_v1alpha1.types.SearchConfig: @@ -3650,7 +3739,7 @@ def delete_search_config( name: Optional[str] = None, retry: OptionalRetry = 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 search configuration inside a corpus. @@ -3695,8 +3784,10 @@ def sample_delete_search_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3745,7 +3836,7 @@ def list_search_configs( 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.ListSearchConfigsPager: r"""Lists all search configurations inside a corpus. @@ -3791,8 +3882,10 @@ def sample_list_search_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.visionai_v1alpha1.services.warehouse.pagers.ListSearchConfigsPager: @@ -3863,7 +3956,7 @@ def search_assets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchAssetsPager: r"""Search media asset. @@ -3900,8 +3993,10 @@ def sample_search_assets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.visionai_v1alpha1.services.warehouse.pagers.SearchAssetsPager: @@ -3972,7 +4067,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. @@ -3983,8 +4078,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. @@ -4025,7 +4122,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. @@ -4036,8 +4133,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. @@ -4078,7 +4177,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. @@ -4094,8 +4193,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 """ @@ -4132,7 +4233,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. @@ -4147,8 +4248,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 """ @@ -4185,7 +4288,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. @@ -4198,8 +4301,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. @@ -4304,7 +4409,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. @@ -4318,8 +4423,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. @@ -4424,7 +4531,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. @@ -4439,8 +4546,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. @@ -4482,7 +4591,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. @@ -4493,8 +4602,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. @@ -4535,7 +4646,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. @@ -4546,8 +4657,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-visionai/google/cloud/visionai_v1alpha1/services/warehouse/pagers.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/pagers.py index e0e0be75096d..0400da1a5a5a 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/pagers.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/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 = warehouse.ListAssetsRequest(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 = warehouse.ListAssetsRequest(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 = warehouse.ListCorporaRequest(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 = warehouse.ListCorporaRequest(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 = warehouse.ListDataSchemasRequest(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 = warehouse.ListDataSchemasRequest(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 = warehouse.ListAnnotationsRequest(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 = warehouse.ListAnnotationsRequest(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 = warehouse.ListSearchConfigsRequest(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 = warehouse.ListSearchConfigsRequest(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 = warehouse.SearchAssetsRequest(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 = warehouse.SearchAssetsRequest(request) diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/transports/grpc.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/transports/grpc.py index b46c7394f0f3..6188aa7e2b2d 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/transports/grpc.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/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.visionai_v1alpha1.types import warehouse from .base import DEFAULT_CLIENT_INFO, WarehouseTransport +try: + from google.api_core import client_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.visionai.v1alpha1.Warehouse", + "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.visionai.v1alpha1.Warehouse", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WarehouseGrpcTransport(WarehouseTransport): """gRPC backend transport for Warehouse. @@ -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 create_asset(self) -> Callable[[warehouse.CreateAssetRequest], warehouse.Ass # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_asset" not in self._stubs: - self._stubs["create_asset"] = self.grpc_channel.unary_unary( + self._stubs["create_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/CreateAsset", request_serializer=warehouse.CreateAssetRequest.serialize, response_deserializer=warehouse.Asset.deserialize, @@ -295,7 +383,7 @@ def update_asset(self) -> Callable[[warehouse.UpdateAssetRequest], warehouse.Ass # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_asset" not in self._stubs: - self._stubs["update_asset"] = self.grpc_channel.unary_unary( + self._stubs["update_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/UpdateAsset", request_serializer=warehouse.UpdateAssetRequest.serialize, response_deserializer=warehouse.Asset.deserialize, @@ -319,7 +407,7 @@ def get_asset(self) -> Callable[[warehouse.GetAssetRequest], warehouse.Asset]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_asset" not in self._stubs: - self._stubs["get_asset"] = self.grpc_channel.unary_unary( + self._stubs["get_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/GetAsset", request_serializer=warehouse.GetAssetRequest.serialize, response_deserializer=warehouse.Asset.deserialize, @@ -345,7 +433,7 @@ def list_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_assets" not in self._stubs: - self._stubs["list_assets"] = self.grpc_channel.unary_unary( + self._stubs["list_assets"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/ListAssets", request_serializer=warehouse.ListAssetsRequest.serialize, response_deserializer=warehouse.ListAssetsResponse.deserialize, @@ -371,7 +459,7 @@ def delete_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_asset" not in self._stubs: - self._stubs["delete_asset"] = self.grpc_channel.unary_unary( + self._stubs["delete_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/DeleteAsset", request_serializer=warehouse.DeleteAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -397,7 +485,7 @@ def create_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_corpus" not in self._stubs: - self._stubs["create_corpus"] = self.grpc_channel.unary_unary( + self._stubs["create_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/CreateCorpus", request_serializer=warehouse.CreateCorpusRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -421,7 +509,7 @@ def get_corpus(self) -> Callable[[warehouse.GetCorpusRequest], warehouse.Corpus] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_corpus" not in self._stubs: - self._stubs["get_corpus"] = self.grpc_channel.unary_unary( + self._stubs["get_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/GetCorpus", request_serializer=warehouse.GetCorpusRequest.serialize, response_deserializer=warehouse.Corpus.deserialize, @@ -447,7 +535,7 @@ def update_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_corpus" not in self._stubs: - self._stubs["update_corpus"] = self.grpc_channel.unary_unary( + self._stubs["update_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/UpdateCorpus", request_serializer=warehouse.UpdateCorpusRequest.serialize, response_deserializer=warehouse.Corpus.deserialize, @@ -473,7 +561,7 @@ def list_corpora( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_corpora" not in self._stubs: - self._stubs["list_corpora"] = self.grpc_channel.unary_unary( + self._stubs["list_corpora"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/ListCorpora", request_serializer=warehouse.ListCorporaRequest.serialize, response_deserializer=warehouse.ListCorporaResponse.deserialize, @@ -500,7 +588,7 @@ def delete_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_corpus" not in self._stubs: - self._stubs["delete_corpus"] = self.grpc_channel.unary_unary( + self._stubs["delete_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/DeleteCorpus", request_serializer=warehouse.DeleteCorpusRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -526,7 +614,7 @@ def create_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_data_schema" not in self._stubs: - self._stubs["create_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["create_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/CreateDataSchema", request_serializer=warehouse.CreateDataSchemaRequest.serialize, response_deserializer=warehouse.DataSchema.deserialize, @@ -552,7 +640,7 @@ def update_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_data_schema" not in self._stubs: - self._stubs["update_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["update_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/UpdateDataSchema", request_serializer=warehouse.UpdateDataSchemaRequest.serialize, response_deserializer=warehouse.DataSchema.deserialize, @@ -578,7 +666,7 @@ def get_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_schema" not in self._stubs: - self._stubs["get_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["get_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/GetDataSchema", request_serializer=warehouse.GetDataSchemaRequest.serialize, response_deserializer=warehouse.DataSchema.deserialize, @@ -604,7 +692,7 @@ def delete_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_data_schema" not in self._stubs: - self._stubs["delete_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["delete_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/DeleteDataSchema", request_serializer=warehouse.DeleteDataSchemaRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -632,7 +720,7 @@ def list_data_schemas( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_data_schemas" not in self._stubs: - self._stubs["list_data_schemas"] = self.grpc_channel.unary_unary( + self._stubs["list_data_schemas"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/ListDataSchemas", request_serializer=warehouse.ListDataSchemasRequest.serialize, response_deserializer=warehouse.ListDataSchemasResponse.deserialize, @@ -658,7 +746,7 @@ def create_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_annotation" not in self._stubs: - self._stubs["create_annotation"] = self.grpc_channel.unary_unary( + self._stubs["create_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/CreateAnnotation", request_serializer=warehouse.CreateAnnotationRequest.serialize, response_deserializer=warehouse.Annotation.deserialize, @@ -684,7 +772,7 @@ def get_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_annotation" not in self._stubs: - self._stubs["get_annotation"] = self.grpc_channel.unary_unary( + self._stubs["get_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/GetAnnotation", request_serializer=warehouse.GetAnnotationRequest.serialize, response_deserializer=warehouse.Annotation.deserialize, @@ -712,7 +800,7 @@ def list_annotations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_annotations" not in self._stubs: - self._stubs["list_annotations"] = self.grpc_channel.unary_unary( + self._stubs["list_annotations"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/ListAnnotations", request_serializer=warehouse.ListAnnotationsRequest.serialize, response_deserializer=warehouse.ListAnnotationsResponse.deserialize, @@ -738,7 +826,7 @@ def update_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_annotation" not in self._stubs: - self._stubs["update_annotation"] = self.grpc_channel.unary_unary( + self._stubs["update_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/UpdateAnnotation", request_serializer=warehouse.UpdateAnnotationRequest.serialize, response_deserializer=warehouse.Annotation.deserialize, @@ -764,7 +852,7 @@ def delete_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_annotation" not in self._stubs: - self._stubs["delete_annotation"] = self.grpc_channel.unary_unary( + self._stubs["delete_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/DeleteAnnotation", request_serializer=warehouse.DeleteAnnotationRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -794,7 +882,7 @@ def ingest_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "ingest_asset" not in self._stubs: - self._stubs["ingest_asset"] = self.grpc_channel.stream_stream( + self._stubs["ingest_asset"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1alpha1.Warehouse/IngestAsset", request_serializer=warehouse.IngestAssetRequest.serialize, response_deserializer=warehouse.IngestAssetResponse.deserialize, @@ -824,7 +912,7 @@ def clip_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "clip_asset" not in self._stubs: - self._stubs["clip_asset"] = self.grpc_channel.unary_unary( + self._stubs["clip_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/ClipAsset", request_serializer=warehouse.ClipAssetRequest.serialize, response_deserializer=warehouse.ClipAssetResponse.deserialize, @@ -852,7 +940,7 @@ def generate_hls_uri( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_hls_uri" not in self._stubs: - self._stubs["generate_hls_uri"] = self.grpc_channel.unary_unary( + self._stubs["generate_hls_uri"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/GenerateHlsUri", request_serializer=warehouse.GenerateHlsUriRequest.serialize, response_deserializer=warehouse.GenerateHlsUriResponse.deserialize, @@ -893,7 +981,7 @@ def create_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_search_config" not in self._stubs: - self._stubs["create_search_config"] = self.grpc_channel.unary_unary( + self._stubs["create_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/CreateSearchConfig", request_serializer=warehouse.CreateSearchConfigRequest.serialize, response_deserializer=warehouse.SearchConfig.deserialize, @@ -933,7 +1021,7 @@ def update_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_search_config" not in self._stubs: - self._stubs["update_search_config"] = self.grpc_channel.unary_unary( + self._stubs["update_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/UpdateSearchConfig", request_serializer=warehouse.UpdateSearchConfigRequest.serialize, response_deserializer=warehouse.SearchConfig.deserialize, @@ -959,7 +1047,7 @@ def get_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_search_config" not in self._stubs: - self._stubs["get_search_config"] = self.grpc_channel.unary_unary( + self._stubs["get_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/GetSearchConfig", request_serializer=warehouse.GetSearchConfigRequest.serialize, response_deserializer=warehouse.SearchConfig.deserialize, @@ -988,7 +1076,7 @@ def delete_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_search_config" not in self._stubs: - self._stubs["delete_search_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/DeleteSearchConfig", request_serializer=warehouse.DeleteSearchConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1016,7 +1104,7 @@ def list_search_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_search_configs" not in self._stubs: - self._stubs["list_search_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_search_configs"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/ListSearchConfigs", request_serializer=warehouse.ListSearchConfigsRequest.serialize, response_deserializer=warehouse.ListSearchConfigsResponse.deserialize, @@ -1042,7 +1130,7 @@ def search_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_assets" not in self._stubs: - self._stubs["search_assets"] = self.grpc_channel.unary_unary( + self._stubs["search_assets"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/SearchAssets", request_serializer=warehouse.SearchAssetsRequest.serialize, response_deserializer=warehouse.SearchAssetsResponse.deserialize, @@ -1050,7 +1138,7 @@ def search_assets( return self._stubs["search_assets"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -1062,7 +1150,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, @@ -1079,7 +1167,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, @@ -1096,7 +1184,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, @@ -1115,7 +1203,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, @@ -1134,7 +1222,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, @@ -1151,7 +1239,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, @@ -1176,7 +1264,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, @@ -1202,7 +1290,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, @@ -1231,7 +1319,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-visionai/google/cloud/visionai_v1alpha1/services/warehouse/transports/grpc_asyncio.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/transports/grpc_asyncio.py index d7163df8de8e..199f14d1cedc 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/transports/grpc_asyncio.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/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.visionai_v1alpha1.types import warehouse from .base import DEFAULT_CLIENT_INFO, WarehouseTransport from .grpc import WarehouseGrpcTransport +try: + from google.api_core import client_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.visionai.v1alpha1.Warehouse", + "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.visionai.v1alpha1.Warehouse", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WarehouseGrpcAsyncIOTransport(WarehouseTransport): """gRPC AsyncIO backend transport for Warehouse. @@ -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 create_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_asset" not in self._stubs: - self._stubs["create_asset"] = self.grpc_channel.unary_unary( + self._stubs["create_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/CreateAsset", request_serializer=warehouse.CreateAssetRequest.serialize, response_deserializer=warehouse.Asset.deserialize, @@ -309,7 +394,7 @@ def update_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_asset" not in self._stubs: - self._stubs["update_asset"] = self.grpc_channel.unary_unary( + self._stubs["update_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/UpdateAsset", request_serializer=warehouse.UpdateAssetRequest.serialize, response_deserializer=warehouse.Asset.deserialize, @@ -335,7 +420,7 @@ def get_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_asset" not in self._stubs: - self._stubs["get_asset"] = self.grpc_channel.unary_unary( + self._stubs["get_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/GetAsset", request_serializer=warehouse.GetAssetRequest.serialize, response_deserializer=warehouse.Asset.deserialize, @@ -363,7 +448,7 @@ def list_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_assets" not in self._stubs: - self._stubs["list_assets"] = self.grpc_channel.unary_unary( + self._stubs["list_assets"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/ListAssets", request_serializer=warehouse.ListAssetsRequest.serialize, response_deserializer=warehouse.ListAssetsResponse.deserialize, @@ -389,7 +474,7 @@ def delete_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_asset" not in self._stubs: - self._stubs["delete_asset"] = self.grpc_channel.unary_unary( + self._stubs["delete_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/DeleteAsset", request_serializer=warehouse.DeleteAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -415,7 +500,7 @@ def create_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_corpus" not in self._stubs: - self._stubs["create_corpus"] = self.grpc_channel.unary_unary( + self._stubs["create_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/CreateCorpus", request_serializer=warehouse.CreateCorpusRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -441,7 +526,7 @@ def get_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_corpus" not in self._stubs: - self._stubs["get_corpus"] = self.grpc_channel.unary_unary( + self._stubs["get_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/GetCorpus", request_serializer=warehouse.GetCorpusRequest.serialize, response_deserializer=warehouse.Corpus.deserialize, @@ -467,7 +552,7 @@ def update_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_corpus" not in self._stubs: - self._stubs["update_corpus"] = self.grpc_channel.unary_unary( + self._stubs["update_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/UpdateCorpus", request_serializer=warehouse.UpdateCorpusRequest.serialize, response_deserializer=warehouse.Corpus.deserialize, @@ -495,7 +580,7 @@ def list_corpora( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_corpora" not in self._stubs: - self._stubs["list_corpora"] = self.grpc_channel.unary_unary( + self._stubs["list_corpora"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/ListCorpora", request_serializer=warehouse.ListCorporaRequest.serialize, response_deserializer=warehouse.ListCorporaResponse.deserialize, @@ -522,7 +607,7 @@ def delete_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_corpus" not in self._stubs: - self._stubs["delete_corpus"] = self.grpc_channel.unary_unary( + self._stubs["delete_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/DeleteCorpus", request_serializer=warehouse.DeleteCorpusRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -548,7 +633,7 @@ def create_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_data_schema" not in self._stubs: - self._stubs["create_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["create_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/CreateDataSchema", request_serializer=warehouse.CreateDataSchemaRequest.serialize, response_deserializer=warehouse.DataSchema.deserialize, @@ -574,7 +659,7 @@ def update_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_data_schema" not in self._stubs: - self._stubs["update_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["update_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/UpdateDataSchema", request_serializer=warehouse.UpdateDataSchemaRequest.serialize, response_deserializer=warehouse.DataSchema.deserialize, @@ -600,7 +685,7 @@ def get_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_schema" not in self._stubs: - self._stubs["get_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["get_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/GetDataSchema", request_serializer=warehouse.GetDataSchemaRequest.serialize, response_deserializer=warehouse.DataSchema.deserialize, @@ -626,7 +711,7 @@ def delete_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_data_schema" not in self._stubs: - self._stubs["delete_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["delete_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/DeleteDataSchema", request_serializer=warehouse.DeleteDataSchemaRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -654,7 +739,7 @@ def list_data_schemas( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_data_schemas" not in self._stubs: - self._stubs["list_data_schemas"] = self.grpc_channel.unary_unary( + self._stubs["list_data_schemas"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/ListDataSchemas", request_serializer=warehouse.ListDataSchemasRequest.serialize, response_deserializer=warehouse.ListDataSchemasResponse.deserialize, @@ -680,7 +765,7 @@ def create_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_annotation" not in self._stubs: - self._stubs["create_annotation"] = self.grpc_channel.unary_unary( + self._stubs["create_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/CreateAnnotation", request_serializer=warehouse.CreateAnnotationRequest.serialize, response_deserializer=warehouse.Annotation.deserialize, @@ -706,7 +791,7 @@ def get_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_annotation" not in self._stubs: - self._stubs["get_annotation"] = self.grpc_channel.unary_unary( + self._stubs["get_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/GetAnnotation", request_serializer=warehouse.GetAnnotationRequest.serialize, response_deserializer=warehouse.Annotation.deserialize, @@ -734,7 +819,7 @@ def list_annotations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_annotations" not in self._stubs: - self._stubs["list_annotations"] = self.grpc_channel.unary_unary( + self._stubs["list_annotations"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/ListAnnotations", request_serializer=warehouse.ListAnnotationsRequest.serialize, response_deserializer=warehouse.ListAnnotationsResponse.deserialize, @@ -760,7 +845,7 @@ def update_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_annotation" not in self._stubs: - self._stubs["update_annotation"] = self.grpc_channel.unary_unary( + self._stubs["update_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/UpdateAnnotation", request_serializer=warehouse.UpdateAnnotationRequest.serialize, response_deserializer=warehouse.Annotation.deserialize, @@ -786,7 +871,7 @@ def delete_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_annotation" not in self._stubs: - self._stubs["delete_annotation"] = self.grpc_channel.unary_unary( + self._stubs["delete_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/DeleteAnnotation", request_serializer=warehouse.DeleteAnnotationRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -818,7 +903,7 @@ def ingest_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "ingest_asset" not in self._stubs: - self._stubs["ingest_asset"] = self.grpc_channel.stream_stream( + self._stubs["ingest_asset"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1alpha1.Warehouse/IngestAsset", request_serializer=warehouse.IngestAssetRequest.serialize, response_deserializer=warehouse.IngestAssetResponse.deserialize, @@ -848,7 +933,7 @@ def clip_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "clip_asset" not in self._stubs: - self._stubs["clip_asset"] = self.grpc_channel.unary_unary( + self._stubs["clip_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/ClipAsset", request_serializer=warehouse.ClipAssetRequest.serialize, response_deserializer=warehouse.ClipAssetResponse.deserialize, @@ -878,7 +963,7 @@ def generate_hls_uri( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_hls_uri" not in self._stubs: - self._stubs["generate_hls_uri"] = self.grpc_channel.unary_unary( + self._stubs["generate_hls_uri"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/GenerateHlsUri", request_serializer=warehouse.GenerateHlsUriRequest.serialize, response_deserializer=warehouse.GenerateHlsUriResponse.deserialize, @@ -921,7 +1006,7 @@ def create_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_search_config" not in self._stubs: - self._stubs["create_search_config"] = self.grpc_channel.unary_unary( + self._stubs["create_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/CreateSearchConfig", request_serializer=warehouse.CreateSearchConfigRequest.serialize, response_deserializer=warehouse.SearchConfig.deserialize, @@ -963,7 +1048,7 @@ def update_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_search_config" not in self._stubs: - self._stubs["update_search_config"] = self.grpc_channel.unary_unary( + self._stubs["update_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/UpdateSearchConfig", request_serializer=warehouse.UpdateSearchConfigRequest.serialize, response_deserializer=warehouse.SearchConfig.deserialize, @@ -991,7 +1076,7 @@ def get_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_search_config" not in self._stubs: - self._stubs["get_search_config"] = self.grpc_channel.unary_unary( + self._stubs["get_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/GetSearchConfig", request_serializer=warehouse.GetSearchConfigRequest.serialize, response_deserializer=warehouse.SearchConfig.deserialize, @@ -1020,7 +1105,7 @@ def delete_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_search_config" not in self._stubs: - self._stubs["delete_search_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/DeleteSearchConfig", request_serializer=warehouse.DeleteSearchConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1049,7 +1134,7 @@ def list_search_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_search_configs" not in self._stubs: - self._stubs["list_search_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_search_configs"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/ListSearchConfigs", request_serializer=warehouse.ListSearchConfigsRequest.serialize, response_deserializer=warehouse.ListSearchConfigsResponse.deserialize, @@ -1077,7 +1162,7 @@ def search_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_assets" not in self._stubs: - self._stubs["search_assets"] = self.grpc_channel.unary_unary( + self._stubs["search_assets"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/SearchAssets", request_serializer=warehouse.SearchAssetsRequest.serialize, response_deserializer=warehouse.SearchAssetsResponse.deserialize, @@ -1335,7 +1420,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: @@ -1351,7 +1436,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, @@ -1368,7 +1453,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, @@ -1385,7 +1470,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, @@ -1404,7 +1489,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, @@ -1423,7 +1508,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, @@ -1440,7 +1525,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, @@ -1465,7 +1550,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, @@ -1491,7 +1576,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, @@ -1520,7 +1605,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-visionai/google/cloud/visionai_v1alpha1/services/warehouse/transports/rest.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/transports/rest.py index e76919d84250..dbc0337847e6 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/transports/rest.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/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, @@ -280,8 +288,10 @@ def post_update_search_config(self, response): """ def pre_clip_asset( - self, request: warehouse.ClipAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.ClipAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.ClipAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.ClipAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for clip_asset Override in a subclass to manipulate the request or metadata @@ -303,8 +313,10 @@ def post_clip_asset( def pre_create_annotation( self, request: warehouse.CreateAnnotationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.CreateAnnotationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.CreateAnnotationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_annotation Override in a subclass to manipulate the request or metadata @@ -324,8 +336,10 @@ def post_create_annotation( return response def pre_create_asset( - self, request: warehouse.CreateAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.CreateAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.CreateAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.CreateAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_asset Override in a subclass to manipulate the request or metadata @@ -345,8 +359,8 @@ def post_create_asset(self, response: warehouse.Asset) -> warehouse.Asset: def pre_create_corpus( self, request: warehouse.CreateCorpusRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.CreateCorpusRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.CreateCorpusRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_corpus Override in a subclass to manipulate the request or metadata @@ -368,8 +382,10 @@ def post_create_corpus( def pre_create_data_schema( self, request: warehouse.CreateDataSchemaRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.CreateDataSchemaRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.CreateDataSchemaRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_data_schema Override in a subclass to manipulate the request or metadata @@ -391,8 +407,10 @@ def post_create_data_schema( def pre_create_search_config( self, request: warehouse.CreateSearchConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.CreateSearchConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.CreateSearchConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_search_config Override in a subclass to manipulate the request or metadata @@ -414,8 +432,10 @@ def post_create_search_config( def pre_delete_annotation( self, request: warehouse.DeleteAnnotationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.DeleteAnnotationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.DeleteAnnotationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_annotation Override in a subclass to manipulate the request or metadata @@ -424,8 +444,10 @@ def pre_delete_annotation( return request, metadata def pre_delete_asset( - self, request: warehouse.DeleteAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.DeleteAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.DeleteAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.DeleteAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_asset Override in a subclass to manipulate the request or metadata @@ -447,8 +469,8 @@ def post_delete_asset( def pre_delete_corpus( self, request: warehouse.DeleteCorpusRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.DeleteCorpusRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.DeleteCorpusRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_corpus Override in a subclass to manipulate the request or metadata @@ -459,8 +481,10 @@ def pre_delete_corpus( def pre_delete_data_schema( self, request: warehouse.DeleteDataSchemaRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.DeleteDataSchemaRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.DeleteDataSchemaRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_data_schema Override in a subclass to manipulate the request or metadata @@ -471,8 +495,10 @@ def pre_delete_data_schema( def pre_delete_search_config( self, request: warehouse.DeleteSearchConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.DeleteSearchConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.DeleteSearchConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_search_config Override in a subclass to manipulate the request or metadata @@ -483,8 +509,10 @@ def pre_delete_search_config( def pre_generate_hls_uri( self, request: warehouse.GenerateHlsUriRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.GenerateHlsUriRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.GenerateHlsUriRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for generate_hls_uri Override in a subclass to manipulate the request or metadata @@ -506,8 +534,8 @@ def post_generate_hls_uri( def pre_get_annotation( self, request: warehouse.GetAnnotationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.GetAnnotationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.GetAnnotationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_annotation Override in a subclass to manipulate the request or metadata @@ -527,8 +555,10 @@ def post_get_annotation( return response def pre_get_asset( - self, request: warehouse.GetAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.GetAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.GetAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.GetAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_asset Override in a subclass to manipulate the request or metadata @@ -546,8 +576,10 @@ def post_get_asset(self, response: warehouse.Asset) -> warehouse.Asset: return response def pre_get_corpus( - self, request: warehouse.GetCorpusRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.GetCorpusRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.GetCorpusRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.GetCorpusRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_corpus Override in a subclass to manipulate the request or metadata @@ -567,8 +599,8 @@ def post_get_corpus(self, response: warehouse.Corpus) -> warehouse.Corpus: def pre_get_data_schema( self, request: warehouse.GetDataSchemaRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.GetDataSchemaRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.GetDataSchemaRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_data_schema Override in a subclass to manipulate the request or metadata @@ -590,8 +622,10 @@ def post_get_data_schema( def pre_get_search_config( self, request: warehouse.GetSearchConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.GetSearchConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.GetSearchConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_search_config Override in a subclass to manipulate the request or metadata @@ -613,8 +647,10 @@ def post_get_search_config( def pre_list_annotations( self, request: warehouse.ListAnnotationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.ListAnnotationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.ListAnnotationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_annotations Override in a subclass to manipulate the request or metadata @@ -634,8 +670,10 @@ def post_list_annotations( return response def pre_list_assets( - self, request: warehouse.ListAssetsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.ListAssetsRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.ListAssetsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.ListAssetsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_assets Override in a subclass to manipulate the request or metadata @@ -655,8 +693,10 @@ def post_list_assets( return response def pre_list_corpora( - self, request: warehouse.ListCorporaRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.ListCorporaRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.ListCorporaRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.ListCorporaRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_corpora Override in a subclass to manipulate the request or metadata @@ -678,8 +718,10 @@ def post_list_corpora( def pre_list_data_schemas( self, request: warehouse.ListDataSchemasRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.ListDataSchemasRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.ListDataSchemasRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_data_schemas Override in a subclass to manipulate the request or metadata @@ -701,8 +743,10 @@ def post_list_data_schemas( def pre_list_search_configs( self, request: warehouse.ListSearchConfigsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.ListSearchConfigsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.ListSearchConfigsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_search_configs Override in a subclass to manipulate the request or metadata @@ -724,8 +768,8 @@ def post_list_search_configs( def pre_search_assets( self, request: warehouse.SearchAssetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.SearchAssetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.SearchAssetsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search_assets Override in a subclass to manipulate the request or metadata @@ -747,8 +791,10 @@ def post_search_assets( def pre_update_annotation( self, request: warehouse.UpdateAnnotationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.UpdateAnnotationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.UpdateAnnotationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_annotation Override in a subclass to manipulate the request or metadata @@ -768,8 +814,10 @@ def post_update_annotation( return response def pre_update_asset( - self, request: warehouse.UpdateAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.UpdateAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.UpdateAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.UpdateAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_asset Override in a subclass to manipulate the request or metadata @@ -789,8 +837,8 @@ def post_update_asset(self, response: warehouse.Asset) -> warehouse.Asset: def pre_update_corpus( self, request: warehouse.UpdateCorpusRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.UpdateCorpusRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.UpdateCorpusRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_corpus Override in a subclass to manipulate the request or metadata @@ -810,8 +858,10 @@ def post_update_corpus(self, response: warehouse.Corpus) -> warehouse.Corpus: def pre_update_data_schema( self, request: warehouse.UpdateDataSchemaRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.UpdateDataSchemaRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.UpdateDataSchemaRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_data_schema Override in a subclass to manipulate the request or metadata @@ -833,8 +883,10 @@ def post_update_data_schema( def pre_update_search_config( self, request: warehouse.UpdateSearchConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.UpdateSearchConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.UpdateSearchConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_search_config Override in a subclass to manipulate the request or metadata @@ -856,8 +908,10 @@ def post_update_search_config( 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 @@ -879,8 +933,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 @@ -902,8 +958,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 @@ -923,8 +981,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 @@ -944,8 +1004,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 @@ -967,8 +1030,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 @@ -988,8 +1053,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 @@ -1009,8 +1076,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 @@ -1032,8 +1101,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 @@ -1234,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]]] = (), ) -> warehouse.ClipAssetResponse: r"""Call the clip asset method over HTTP. @@ -1244,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: ~.warehouse.ClipAssetResponse: @@ -1255,6 +1328,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseClipAsset._get_http_options() ) + request, metadata = self._interceptor.pre_clip_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseClipAsset._get_transcoded_request( @@ -1273,6 +1347,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.ClipAsset", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ClipAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ClipAsset._get_response( self._host, @@ -1294,7 +1395,29 @@ def __call__( pb_resp = warehouse.ClipAssetResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_clip_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ClipAssetResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.WarehouseClient.clip_asset", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ClipAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateAnnotation( @@ -1332,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]]] = (), ) -> warehouse.Annotation: r"""Call the create annotation method over HTTP. @@ -1342,8 +1465,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.Annotation: @@ -1356,6 +1481,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateAnnotation._get_http_options() ) + request, metadata = self._interceptor.pre_create_annotation( request, metadata ) @@ -1372,6 +1498,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.CreateAnnotation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "CreateAnnotation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateAnnotation._get_response( self._host, @@ -1393,7 +1546,29 @@ def __call__( pb_resp = warehouse.Annotation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_annotation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Annotation.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.WarehouseClient.create_annotation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "CreateAnnotation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateAsset(_BaseWarehouseRestTransport._BaseCreateAsset, WarehouseRestStub): @@ -1429,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]]] = (), ) -> warehouse.Asset: r"""Call the create asset method over HTTP. @@ -1440,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: ~.warehouse.Asset: @@ -1458,6 +1635,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateAsset._get_http_options() ) + request, metadata = self._interceptor.pre_create_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseCreateAsset._get_transcoded_request( @@ -1476,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.visionai_v1alpha1.WarehouseClient.CreateAsset", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "CreateAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateAsset._get_response( self._host, @@ -1497,7 +1702,29 @@ def __call__( pb_resp = warehouse.Asset.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Asset.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.WarehouseClient.create_asset", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "CreateAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCorpus( @@ -1535,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create corpus method over HTTP. @@ -1545,8 +1772,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1559,6 +1788,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateCorpus._get_http_options() ) + request, metadata = self._interceptor.pre_create_corpus(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseCreateCorpus._get_transcoded_request( @@ -1577,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.CreateCorpus", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "CreateCorpus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateCorpus._get_response( self._host, @@ -1596,7 +1853,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_corpus(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.WarehouseClient.create_corpus", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "CreateCorpus", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateDataSchema( @@ -1634,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]]] = (), ) -> warehouse.DataSchema: r"""Call the create data schema method over HTTP. @@ -1644,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: ~.warehouse.DataSchema: @@ -1658,6 +1939,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateDataSchema._get_http_options() ) + request, metadata = self._interceptor.pre_create_data_schema( request, metadata ) @@ -1674,6 +1956,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.CreateDataSchema", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "CreateDataSchema", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateDataSchema._get_response( self._host, @@ -1695,7 +2004,29 @@ def __call__( pb_resp = warehouse.DataSchema.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_data_schema(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.DataSchema.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.WarehouseClient.create_data_schema", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "CreateDataSchema", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSearchConfig( @@ -1733,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]]] = (), ) -> warehouse.SearchConfig: r"""Call the create search config method over HTTP. @@ -1744,8 +2075,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.SearchConfig: @@ -1758,6 +2091,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateSearchConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_search_config( request, metadata ) @@ -1774,6 +2108,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.CreateSearchConfig", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "CreateSearchConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateSearchConfig._get_response( self._host, @@ -1795,7 +2156,29 @@ def __call__( pb_resp = warehouse.SearchConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_search_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.SearchConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.WarehouseClient.create_search_config", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "CreateSearchConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAnnotation( @@ -1832,7 +2215,7 @@ 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 annotation method over HTTP. @@ -1843,13 +2226,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 = ( _BaseWarehouseRestTransport._BaseDeleteAnnotation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_annotation( request, metadata ) @@ -1862,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.DeleteAnnotation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "DeleteAnnotation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteAnnotation._get_response( self._host, @@ -1909,7 +2322,7 @@ 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 asset method over HTTP. @@ -1919,8 +2332,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1933,6 +2348,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseDeleteAsset._get_http_options() ) + request, metadata = self._interceptor.pre_delete_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseDeleteAsset._get_transcoded_request( @@ -1947,6 +2363,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.DeleteAsset", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "DeleteAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteAsset._get_response( self._host, @@ -1965,7 +2408,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_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.WarehouseClient.delete_asset", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "DeleteAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCorpus( @@ -2002,7 +2467,7 @@ 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 corpus method over HTTP. @@ -2012,13 +2477,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 = ( _BaseWarehouseRestTransport._BaseDeleteCorpus._get_http_options() ) + request, metadata = self._interceptor.pre_delete_corpus(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseDeleteCorpus._get_transcoded_request( @@ -2033,6 +2501,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.DeleteCorpus", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "DeleteCorpus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteCorpus._get_response( self._host, @@ -2082,7 +2577,7 @@ 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 data schema method over HTTP. @@ -2092,13 +2587,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 = ( _BaseWarehouseRestTransport._BaseDeleteDataSchema._get_http_options() ) + request, metadata = self._interceptor.pre_delete_data_schema( request, metadata ) @@ -2111,6 +2609,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.DeleteDataSchema", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "DeleteDataSchema", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteDataSchema._get_response( self._host, @@ -2160,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]]] = (), ): r"""Call the delete search config method over HTTP. @@ -2171,13 +2696,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 = ( _BaseWarehouseRestTransport._BaseDeleteSearchConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_search_config( request, metadata ) @@ -2190,6 +2718,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.DeleteSearchConfig", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "DeleteSearchConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteSearchConfig._get_response( self._host, @@ -2240,7 +2795,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.GenerateHlsUriResponse: r"""Call the generate hls uri method over HTTP. @@ -2251,8 +2806,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.GenerateHlsUriResponse: @@ -2264,6 +2821,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGenerateHlsUri._get_http_options() ) + request, metadata = self._interceptor.pre_generate_hls_uri( request, metadata ) @@ -2286,6 +2844,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.GenerateHlsUri", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GenerateHlsUri", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GenerateHlsUri._get_response( self._host, @@ -2307,7 +2892,31 @@ def __call__( pb_resp = warehouse.GenerateHlsUriResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_hls_uri(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.GenerateHlsUriResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.WarehouseClient.generate_hls_uri", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GenerateHlsUri", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAnnotation( @@ -2344,7 +2953,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Call the get annotation method over HTTP. @@ -2355,8 +2964,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.Annotation: @@ -2369,6 +2980,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetAnnotation._get_http_options() ) + request, metadata = self._interceptor.pre_get_annotation(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetAnnotation._get_transcoded_request( @@ -2383,6 +2995,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.GetAnnotation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetAnnotation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetAnnotation._get_response( self._host, @@ -2403,7 +3042,29 @@ def __call__( pb_resp = warehouse.Annotation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_annotation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Annotation.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.WarehouseClient.get_annotation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetAnnotation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAsset(_BaseWarehouseRestTransport._BaseGetAsset, WarehouseRestStub): @@ -2438,7 +3099,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Call the get asset method over HTTP. @@ -2448,8 +3109,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.Asset: @@ -2464,6 +3127,7 @@ def __call__( """ http_options = _BaseWarehouseRestTransport._BaseGetAsset._get_http_options() + request, metadata = self._interceptor.pre_get_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetAsset._get_transcoded_request( @@ -2478,6 +3142,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.GetAsset", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetAsset._get_response( self._host, @@ -2498,7 +3189,29 @@ def __call__( pb_resp = warehouse.Asset.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Asset.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.WarehouseClient.get_asset", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCorpus(_BaseWarehouseRestTransport._BaseGetCorpus, WarehouseRestStub): @@ -2533,7 +3246,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Corpus: r"""Call the get corpus method over HTTP. @@ -2543,8 +3256,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.Corpus: @@ -2558,6 +3273,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetCorpus._get_http_options() ) + request, metadata = self._interceptor.pre_get_corpus(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetCorpus._get_transcoded_request( @@ -2572,6 +3288,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.GetCorpus", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetCorpus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetCorpus._get_response( self._host, @@ -2592,7 +3335,29 @@ def __call__( pb_resp = warehouse.Corpus.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_corpus(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Corpus.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.WarehouseClient.get_corpus", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetCorpus", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDataSchema( @@ -2629,7 +3394,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Call the get data schema method over HTTP. @@ -2639,8 +3404,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.DataSchema: @@ -2653,6 +3420,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetDataSchema._get_http_options() ) + request, metadata = self._interceptor.pre_get_data_schema(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetDataSchema._get_transcoded_request( @@ -2667,6 +3435,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.GetDataSchema", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetDataSchema", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetDataSchema._get_response( self._host, @@ -2687,7 +3482,29 @@ def __call__( pb_resp = warehouse.DataSchema.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_data_schema(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.DataSchema.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.WarehouseClient.get_data_schema", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetDataSchema", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSearchConfig( @@ -2724,7 +3541,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Call the get search config method over HTTP. @@ -2734,8 +3551,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.SearchConfig: @@ -2748,6 +3567,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetSearchConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_search_config( request, metadata ) @@ -2762,6 +3582,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.GetSearchConfig", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetSearchConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetSearchConfig._get_response( self._host, @@ -2782,7 +3629,29 @@ def __call__( pb_resp = warehouse.SearchConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_search_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.SearchConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.WarehouseClient.get_search_config", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetSearchConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _IngestAsset(_BaseWarehouseRestTransport._BaseIngestAsset, WarehouseRestStub): @@ -2795,7 +3664,7 @@ 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 IngestAsset is not available over REST transport" @@ -2835,7 +3704,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListAnnotationsResponse: r"""Call the list annotations method over HTTP. @@ -2846,8 +3715,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.ListAnnotationsResponse: @@ -2859,6 +3730,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListAnnotations._get_http_options() ) + request, metadata = self._interceptor.pre_list_annotations( request, metadata ) @@ -2873,6 +3745,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.ListAnnotations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListAnnotations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListAnnotations._get_response( self._host, @@ -2893,7 +3792,31 @@ def __call__( pb_resp = warehouse.ListAnnotationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_annotations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListAnnotationsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.WarehouseClient.list_annotations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListAnnotations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAssets(_BaseWarehouseRestTransport._BaseListAssets, WarehouseRestStub): @@ -2928,7 +3851,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListAssetsResponse: r"""Call the list assets method over HTTP. @@ -2938,8 +3861,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.ListAssetsResponse: @@ -2949,6 +3874,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListAssets._get_http_options() ) + request, metadata = self._interceptor.pre_list_assets(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseListAssets._get_transcoded_request( @@ -2963,6 +3889,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.ListAssets", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListAssets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListAssets._get_response( self._host, @@ -2983,7 +3936,29 @@ def __call__( pb_resp = warehouse.ListAssetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_assets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListAssetsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.WarehouseClient.list_assets", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListAssets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCorpora(_BaseWarehouseRestTransport._BaseListCorpora, WarehouseRestStub): @@ -3018,7 +3993,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListCorporaResponse: r"""Call the list corpora method over HTTP. @@ -3028,8 +4003,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.ListCorporaResponse: @@ -3039,6 +4016,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListCorpora._get_http_options() ) + request, metadata = self._interceptor.pre_list_corpora(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseListCorpora._get_transcoded_request( @@ -3053,6 +4031,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.ListCorpora", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListCorpora", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListCorpora._get_response( self._host, @@ -3073,7 +4078,29 @@ def __call__( pb_resp = warehouse.ListCorporaResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_corpora(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListCorporaResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.WarehouseClient.list_corpora", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListCorpora", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDataSchemas( @@ -3110,7 +4137,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListDataSchemasResponse: r"""Call the list data schemas method over HTTP. @@ -3120,8 +4147,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.ListDataSchemasResponse: @@ -3131,6 +4160,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListDataSchemas._get_http_options() ) + request, metadata = self._interceptor.pre_list_data_schemas( request, metadata ) @@ -3145,6 +4175,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.ListDataSchemas", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListDataSchemas", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListDataSchemas._get_response( self._host, @@ -3165,7 +4222,31 @@ def __call__( pb_resp = warehouse.ListDataSchemasResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_data_schemas(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListDataSchemasResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.WarehouseClient.list_data_schemas", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListDataSchemas", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSearchConfigs( @@ -3202,7 +4283,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListSearchConfigsResponse: r"""Call the list search configs method over HTTP. @@ -3213,8 +4294,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.ListSearchConfigsResponse: @@ -3226,6 +4309,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListSearchConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_search_configs( request, metadata ) @@ -3238,6 +4322,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.ListSearchConfigs", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListSearchConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListSearchConfigs._get_response( self._host, @@ -3258,7 +4369,31 @@ def __call__( pb_resp = warehouse.ListSearchConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_search_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListSearchConfigsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.WarehouseClient.list_search_configs", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListSearchConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchAssets( @@ -3296,7 +4431,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchAssetsResponse: r"""Call the search assets method over HTTP. @@ -3306,8 +4441,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.SearchAssetsResponse: @@ -3317,6 +4454,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseSearchAssets._get_http_options() ) + request, metadata = self._interceptor.pre_search_assets(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseSearchAssets._get_transcoded_request( @@ -3335,6 +4473,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.SearchAssets", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "SearchAssets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._SearchAssets._get_response( self._host, @@ -3356,7 +4521,29 @@ def __call__( pb_resp = warehouse.SearchAssetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_assets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.SearchAssetsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.WarehouseClient.search_assets", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "SearchAssets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAnnotation( @@ -3394,7 +4581,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Call the update annotation method over HTTP. @@ -3405,8 +4592,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.Annotation: @@ -3419,6 +4608,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateAnnotation._get_http_options() ) + request, metadata = self._interceptor.pre_update_annotation( request, metadata ) @@ -3435,6 +4625,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.UpdateAnnotation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "UpdateAnnotation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateAnnotation._get_response( self._host, @@ -3456,7 +4673,29 @@ def __call__( pb_resp = warehouse.Annotation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_annotation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Annotation.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.WarehouseClient.update_annotation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "UpdateAnnotation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAsset(_BaseWarehouseRestTransport._BaseUpdateAsset, WarehouseRestStub): @@ -3492,7 +4731,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Call the update asset method over HTTP. @@ -3502,8 +4741,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.Asset: @@ -3520,6 +4761,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateAsset._get_http_options() ) + request, metadata = self._interceptor.pre_update_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseUpdateAsset._get_transcoded_request( @@ -3538,6 +4780,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.UpdateAsset", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "UpdateAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateAsset._get_response( self._host, @@ -3559,7 +4828,29 @@ def __call__( pb_resp = warehouse.Asset.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Asset.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.WarehouseClient.update_asset", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "UpdateAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCorpus( @@ -3597,7 +4888,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Corpus: r"""Call the update corpus method over HTTP. @@ -3607,8 +4898,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.Corpus: @@ -3622,6 +4915,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateCorpus._get_http_options() ) + request, metadata = self._interceptor.pre_update_corpus(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseUpdateCorpus._get_transcoded_request( @@ -3640,6 +4934,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.UpdateCorpus", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "UpdateCorpus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateCorpus._get_response( self._host, @@ -3661,7 +4982,29 @@ def __call__( pb_resp = warehouse.Corpus.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_corpus(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Corpus.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.WarehouseClient.update_corpus", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "UpdateCorpus", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDataSchema( @@ -3699,7 +5042,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Call the update data schema method over HTTP. @@ -3709,8 +5052,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.DataSchema: @@ -3723,6 +5068,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateDataSchema._get_http_options() ) + request, metadata = self._interceptor.pre_update_data_schema( request, metadata ) @@ -3739,6 +5085,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.UpdateDataSchema", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "UpdateDataSchema", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateDataSchema._get_response( self._host, @@ -3760,7 +5133,29 @@ def __call__( pb_resp = warehouse.DataSchema.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_data_schema(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.DataSchema.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.WarehouseClient.update_data_schema", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "UpdateDataSchema", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSearchConfig( @@ -3798,7 +5193,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Call the update search config method over HTTP. @@ -3809,8 +5204,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.warehouse.SearchConfig: @@ -3823,6 +5220,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateSearchConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_search_config( request, metadata ) @@ -3839,6 +5237,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.UpdateSearchConfig", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "UpdateSearchConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateSearchConfig._get_response( self._host, @@ -3860,7 +5285,29 @@ def __call__( pb_resp = warehouse.SearchConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_search_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.SearchConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.visionai_v1alpha1.WarehouseClient.update_search_config", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "UpdateSearchConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -4129,7 +5576,7 @@ 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. @@ -4139,8 +5586,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -4149,6 +5598,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetLocation._get_transcoded_request( @@ -4163,6 +5613,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.GetLocation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetLocation._get_response( self._host, @@ -4182,6 +5659,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.visionai_v1alpha1.WarehouseAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4222,7 +5720,7 @@ 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. @@ -4232,8 +5730,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -4242,6 +5742,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseListLocations._get_transcoded_request( @@ -4256,6 +5757,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.ListLocations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListLocations._get_response( self._host, @@ -4275,6 +5803,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.visionai_v1alpha1.WarehouseAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4315,7 +5864,7 @@ 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. @@ -4325,8 +5874,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -4335,6 +5886,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetIamPolicy._get_transcoded_request( @@ -4349,6 +5901,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetIamPolicy._get_response( self._host, @@ -4368,6 +5947,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.visionai_v1alpha1.WarehouseAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4409,7 +6009,7 @@ 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. @@ -4419,8 +6019,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -4429,6 +6031,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseSetIamPolicy._get_transcoded_request( @@ -4447,6 +6050,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._SetIamPolicy._get_response( self._host, @@ -4467,6 +6097,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.visionai_v1alpha1.WarehouseAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4508,7 +6159,7 @@ 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. @@ -4518,8 +6169,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -4528,6 +6181,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -4544,6 +6198,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._TestIamPermissions._get_response( self._host, @@ -4564,6 +6245,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.visionai_v1alpha1.WarehouseAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4605,7 +6307,7 @@ 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. @@ -4615,13 +6317,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 = ( _BaseWarehouseRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -4642,6 +6347,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.CancelOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CancelOperation._get_response( self._host, @@ -4698,7 +6430,7 @@ 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. @@ -4708,13 +6440,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 = ( _BaseWarehouseRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -4729,6 +6464,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteOperation._get_response( self._host, @@ -4784,7 +6546,7 @@ 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. @@ -4794,8 +6556,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -4804,6 +6568,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetOperation._get_transcoded_request( @@ -4818,6 +6583,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetOperation._get_response( self._host, @@ -4837,6 +6629,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.visionai_v1alpha1.WarehouseAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4877,7 +6690,7 @@ 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. @@ -4887,8 +6700,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -4897,6 +6712,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseListOperations._get_transcoded_request( @@ -4911,6 +6727,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.visionai_v1alpha1.WarehouseClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListOperations._get_response( self._host, @@ -4930,6 +6773,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.visionai_v1alpha1.WarehouseAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-visionai/samples/generated_samples/snippet_metadata_google.cloud.visionai.v1.json b/packages/google-cloud-visionai/samples/generated_samples/snippet_metadata_google.cloud.visionai.v1.json index 884707596fd2..55144efe90c6 100644 --- a/packages/google-cloud-visionai/samples/generated_samples/snippet_metadata_google.cloud.visionai.v1.json +++ b/packages/google-cloud-visionai/samples/generated_samples/snippet_metadata_google.cloud.visionai.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-visionai", - "version": "0.1.5" + "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", @@ -373,7 +373,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", @@ -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", @@ -634,7 +634,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", @@ -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.api_core.operation_async.AsyncOperation", @@ -972,7 +972,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1053,7 +1053,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1133,7 +1133,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1214,7 +1214,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.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", @@ -1536,7 +1536,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1616,7 +1616,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1697,7 +1697,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Application", @@ -1777,7 +1777,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Application", @@ -1858,7 +1858,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Draft", @@ -1938,7 +1938,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Draft", @@ -2019,7 +2019,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Instance", @@ -2099,7 +2099,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Instance", @@ -2180,7 +2180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Processor", @@ -2260,7 +2260,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Processor", @@ -2341,7 +2341,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.app_platform.pagers.ListApplicationsAsyncPager", @@ -2421,7 +2421,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.app_platform.pagers.ListApplicationsPager", @@ -2502,7 +2502,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.app_platform.pagers.ListDraftsAsyncPager", @@ -2582,7 +2582,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.app_platform.pagers.ListDraftsPager", @@ -2663,7 +2663,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.app_platform.pagers.ListInstancesAsyncPager", @@ -2743,7 +2743,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.app_platform.pagers.ListInstancesPager", @@ -2824,7 +2824,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.ListPrebuiltProcessorsResponse", @@ -2904,7 +2904,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.ListPrebuiltProcessorsResponse", @@ -2985,7 +2985,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.app_platform.pagers.ListProcessorsAsyncPager", @@ -3065,7 +3065,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.app_platform.pagers.ListProcessorsPager", @@ -3146,7 +3146,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3226,7 +3226,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3307,7 +3307,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3387,7 +3387,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3472,7 +3472,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3556,7 +3556,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3637,7 +3637,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3717,7 +3717,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3802,7 +3802,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3886,7 +3886,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -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", @@ -4055,7 +4055,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4140,7 +4140,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4224,7 +4224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4301,7 +4301,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.HealthCheckResponse", @@ -4377,7 +4377,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.HealthCheckResponse", @@ -4462,7 +4462,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4546,7 +4546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4635,7 +4635,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4723,7 +4723,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4812,7 +4812,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4900,7 +4900,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4989,7 +4989,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5077,7 +5077,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5158,7 +5158,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5238,7 +5238,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5319,7 +5319,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5399,7 +5399,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5480,7 +5480,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5560,7 +5560,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5641,7 +5641,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Analysis", @@ -5721,7 +5721,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Analysis", @@ -5802,7 +5802,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Operator", @@ -5882,7 +5882,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Operator", @@ -5963,7 +5963,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Process", @@ -6043,7 +6043,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Process", @@ -6124,7 +6124,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.live_video_analytics.pagers.ListAnalysesAsyncPager", @@ -6204,7 +6204,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.live_video_analytics.pagers.ListAnalysesPager", @@ -6285,7 +6285,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.live_video_analytics.pagers.ListOperatorsAsyncPager", @@ -6365,7 +6365,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.live_video_analytics.pagers.ListOperatorsPager", @@ -6446,7 +6446,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.live_video_analytics.pagers.ListProcessesAsyncPager", @@ -6526,7 +6526,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.live_video_analytics.pagers.ListProcessesPager", @@ -6607,7 +6607,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.live_video_analytics.pagers.ListPublicOperatorsAsyncPager", @@ -6687,7 +6687,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.live_video_analytics.pagers.ListPublicOperatorsPager", @@ -6772,7 +6772,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.ResolveOperatorInfoResponse", @@ -6856,7 +6856,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.ResolveOperatorInfoResponse", @@ -6941,7 +6941,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7025,7 +7025,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7110,7 +7110,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7194,7 +7194,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7279,7 +7279,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7363,7 +7363,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7440,7 +7440,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Lease", @@ -7516,7 +7516,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Lease", @@ -7593,7 +7593,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1.types.ReceiveEventsResponse]", @@ -7669,7 +7669,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1.types.ReceiveEventsResponse]", @@ -7746,7 +7746,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1.types.ReceivePacketsResponse]", @@ -7822,7 +7822,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1.types.ReceivePacketsResponse]", @@ -7899,7 +7899,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.ReleaseLeaseResponse", @@ -7975,7 +7975,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.ReleaseLeaseResponse", @@ -8052,7 +8052,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Lease", @@ -8128,7 +8128,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Lease", @@ -8205,7 +8205,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1.types.SendPacketsResponse]", @@ -8281,7 +8281,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1.types.SendPacketsResponse]", @@ -8370,7 +8370,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -8458,7 +8458,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -8547,7 +8547,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -8635,7 +8635,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -8724,7 +8724,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -8812,7 +8812,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -8901,7 +8901,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -8989,7 +8989,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9070,7 +9070,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9150,7 +9150,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9231,7 +9231,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9311,7 +9311,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9392,7 +9392,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9472,7 +9472,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9553,7 +9553,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9633,7 +9633,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9714,7 +9714,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.GenerateStreamHlsTokenResponse", @@ -9794,7 +9794,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.GenerateStreamHlsTokenResponse", @@ -9875,7 +9875,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Cluster", @@ -9955,7 +9955,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Cluster", @@ -10036,7 +10036,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Event", @@ -10116,7 +10116,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Event", @@ -10197,7 +10197,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Series", @@ -10277,7 +10277,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Series", @@ -10362,7 +10362,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -10446,7 +10446,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -10527,7 +10527,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Stream", @@ -10607,7 +10607,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Stream", @@ -10688,7 +10688,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.streams_service.pagers.ListClustersAsyncPager", @@ -10768,7 +10768,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.streams_service.pagers.ListClustersPager", @@ -10849,7 +10849,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.streams_service.pagers.ListEventsAsyncPager", @@ -10929,7 +10929,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.streams_service.pagers.ListEventsPager", @@ -11010,7 +11010,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.streams_service.pagers.ListSeriesAsyncPager", @@ -11090,7 +11090,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.streams_service.pagers.ListSeriesPager", @@ -11171,7 +11171,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.streams_service.pagers.ListStreamsAsyncPager", @@ -11251,7 +11251,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.streams_service.pagers.ListStreamsPager", @@ -11340,7 +11340,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11428,7 +11428,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11513,7 +11513,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11597,7 +11597,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11682,7 +11682,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11766,7 +11766,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11851,7 +11851,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11935,7 +11935,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -12020,7 +12020,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -12104,7 +12104,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -12185,7 +12185,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.AddCollectionItemResponse", @@ -12265,7 +12265,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.AddCollectionItemResponse", @@ -12342,7 +12342,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -12418,7 +12418,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -12495,7 +12495,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -12571,7 +12571,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -12648,7 +12648,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.ClipAssetResponse", @@ -12724,7 +12724,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.ClipAssetResponse", @@ -12813,7 +12813,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Annotation", @@ -12901,7 +12901,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Annotation", @@ -12990,7 +12990,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Asset", @@ -13078,7 +13078,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Asset", @@ -13167,7 +13167,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -13255,7 +13255,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -13340,7 +13340,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -13424,7 +13424,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -13509,7 +13509,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.DataSchema", @@ -13593,7 +13593,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.DataSchema", @@ -13682,7 +13682,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -13770,7 +13770,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -13859,7 +13859,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -13947,7 +13947,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -14036,7 +14036,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.SearchConfig", @@ -14124,7 +14124,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.SearchConfig", @@ -14213,7 +14213,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.SearchHypernym", @@ -14301,7 +14301,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.SearchHypernym", @@ -14382,7 +14382,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_annotation" @@ -14459,7 +14459,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_annotation" @@ -14537,7 +14537,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -14617,7 +14617,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -14698,7 +14698,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -14778,7 +14778,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -14859,7 +14859,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_corpus" @@ -14936,7 +14936,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_corpus" @@ -15014,7 +15014,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_data_schema" @@ -15091,7 +15091,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_data_schema" @@ -15169,7 +15169,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -15249,7 +15249,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -15330,7 +15330,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -15410,7 +15410,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -15491,7 +15491,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_search_config" @@ -15568,7 +15568,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_search_config" @@ -15646,7 +15646,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_search_hypernym" @@ -15723,7 +15723,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_search_hypernym" @@ -15797,7 +15797,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -15873,7 +15873,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -15950,7 +15950,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.GenerateHlsUriResponse", @@ -16026,7 +16026,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.GenerateHlsUriResponse", @@ -16103,7 +16103,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.GenerateRetrievalUrlResponse", @@ -16179,7 +16179,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.GenerateRetrievalUrlResponse", @@ -16260,7 +16260,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Annotation", @@ -16340,7 +16340,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Annotation", @@ -16421,7 +16421,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Asset", @@ -16501,7 +16501,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Asset", @@ -16582,7 +16582,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Collection", @@ -16662,7 +16662,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Collection", @@ -16743,7 +16743,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Corpus", @@ -16823,7 +16823,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Corpus", @@ -16904,7 +16904,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.DataSchema", @@ -16984,7 +16984,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.DataSchema", @@ -17065,7 +17065,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.IndexEndpoint", @@ -17145,7 +17145,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.IndexEndpoint", @@ -17226,7 +17226,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Index", @@ -17306,7 +17306,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Index", @@ -17387,7 +17387,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.SearchConfig", @@ -17467,7 +17467,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.SearchConfig", @@ -17548,7 +17548,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.SearchHypernym", @@ -17628,7 +17628,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.SearchHypernym", @@ -17705,7 +17705,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -17781,7 +17781,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -17858,7 +17858,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -17934,7 +17934,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -18011,7 +18011,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1.types.IngestAssetResponse]", @@ -18087,7 +18087,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1.types.IngestAssetResponse]", @@ -18168,7 +18168,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListAnnotationsAsyncPager", @@ -18248,7 +18248,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListAnnotationsPager", @@ -18329,7 +18329,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListAssetsAsyncPager", @@ -18409,7 +18409,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListAssetsPager", @@ -18490,7 +18490,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListCollectionsAsyncPager", @@ -18570,7 +18570,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListCollectionsPager", @@ -18651,7 +18651,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListCorporaAsyncPager", @@ -18731,7 +18731,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListCorporaPager", @@ -18812,7 +18812,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListDataSchemasAsyncPager", @@ -18892,7 +18892,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListDataSchemasPager", @@ -18973,7 +18973,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListIndexEndpointsAsyncPager", @@ -19053,7 +19053,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListIndexEndpointsPager", @@ -19134,7 +19134,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListIndexesAsyncPager", @@ -19214,7 +19214,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListIndexesPager", @@ -19295,7 +19295,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListSearchConfigsAsyncPager", @@ -19375,7 +19375,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListSearchConfigsPager", @@ -19456,7 +19456,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListSearchHypernymsAsyncPager", @@ -19536,7 +19536,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListSearchHypernymsPager", @@ -19617,7 +19617,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.RemoveCollectionItemResponse", @@ -19697,7 +19697,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.RemoveCollectionItemResponse", @@ -19774,7 +19774,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -19850,7 +19850,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -19927,7 +19927,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.SearchAssetsAsyncPager", @@ -20003,7 +20003,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.SearchAssetsPager", @@ -20080,7 +20080,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.SearchIndexEndpointAsyncPager", @@ -20156,7 +20156,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.SearchIndexEndpointPager", @@ -20233,7 +20233,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -20309,7 +20309,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -20394,7 +20394,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Annotation", @@ -20478,7 +20478,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Annotation", @@ -20563,7 +20563,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Asset", @@ -20647,7 +20647,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Asset", @@ -20732,7 +20732,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Collection", @@ -20816,7 +20816,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Collection", @@ -20901,7 +20901,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Corpus", @@ -20985,7 +20985,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Corpus", @@ -21070,7 +21070,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.DataSchema", @@ -21154,7 +21154,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.DataSchema", @@ -21239,7 +21239,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -21323,7 +21323,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -21408,7 +21408,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -21492,7 +21492,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -21577,7 +21577,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.SearchConfig", @@ -21661,7 +21661,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.SearchConfig", @@ -21746,7 +21746,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.SearchHypernym", @@ -21830,7 +21830,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.SearchHypernym", @@ -21907,7 +21907,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -21983,7 +21983,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -22064,7 +22064,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ViewCollectionItemsAsyncPager", @@ -22144,7 +22144,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ViewCollectionItemsPager", @@ -22225,7 +22225,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ViewIndexedAssetsAsyncPager", @@ -22305,7 +22305,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ViewIndexedAssetsPager", diff --git a/packages/google-cloud-visionai/samples/generated_samples/snippet_metadata_google.cloud.visionai.v1alpha1.json b/packages/google-cloud-visionai/samples/generated_samples/snippet_metadata_google.cloud.visionai.v1alpha1.json index e7ec36afcf34..11704c120259 100644 --- a/packages/google-cloud-visionai/samples/generated_samples/snippet_metadata_google.cloud.visionai.v1alpha1.json +++ b/packages/google-cloud-visionai/samples/generated_samples/snippet_metadata_google.cloud.visionai.v1alpha1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-visionai", - "version": "0.1.5" + "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", @@ -373,7 +373,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", @@ -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", @@ -634,7 +634,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", @@ -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.api_core.operation_async.AsyncOperation", @@ -972,7 +972,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1053,7 +1053,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1133,7 +1133,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1214,7 +1214,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.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", @@ -1536,7 +1536,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1616,7 +1616,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1697,7 +1697,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Application", @@ -1777,7 +1777,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Application", @@ -1858,7 +1858,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Draft", @@ -1938,7 +1938,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Draft", @@ -2019,7 +2019,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Instance", @@ -2099,7 +2099,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Instance", @@ -2180,7 +2180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Processor", @@ -2260,7 +2260,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Processor", @@ -2341,7 +2341,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListApplicationsAsyncPager", @@ -2421,7 +2421,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListApplicationsPager", @@ -2502,7 +2502,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListDraftsAsyncPager", @@ -2582,7 +2582,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListDraftsPager", @@ -2663,7 +2663,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListInstancesAsyncPager", @@ -2743,7 +2743,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListInstancesPager", @@ -2824,7 +2824,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.ListPrebuiltProcessorsResponse", @@ -2904,7 +2904,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.ListPrebuiltProcessorsResponse", @@ -2985,7 +2985,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListProcessorsAsyncPager", @@ -3065,7 +3065,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListProcessorsPager", @@ -3146,7 +3146,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3226,7 +3226,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3307,7 +3307,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3387,7 +3387,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3472,7 +3472,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3556,7 +3556,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3637,7 +3637,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3717,7 +3717,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3802,7 +3802,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3886,7 +3886,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -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", @@ -4055,7 +4055,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4140,7 +4140,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4224,7 +4224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4313,7 +4313,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4401,7 +4401,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4482,7 +4482,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4562,7 +4562,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4643,7 +4643,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Analysis", @@ -4723,7 +4723,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Analysis", @@ -4804,7 +4804,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.live_video_analytics.pagers.ListAnalysesAsyncPager", @@ -4884,7 +4884,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.live_video_analytics.pagers.ListAnalysesPager", @@ -4969,7 +4969,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5053,7 +5053,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5130,7 +5130,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Lease", @@ -5206,7 +5206,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Lease", @@ -5283,7 +5283,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1alpha1.types.ReceiveEventsResponse]", @@ -5359,7 +5359,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1alpha1.types.ReceiveEventsResponse]", @@ -5436,7 +5436,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1alpha1.types.ReceivePacketsResponse]", @@ -5512,7 +5512,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1alpha1.types.ReceivePacketsResponse]", @@ -5589,7 +5589,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.ReleaseLeaseResponse", @@ -5665,7 +5665,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.ReleaseLeaseResponse", @@ -5742,7 +5742,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Lease", @@ -5818,7 +5818,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Lease", @@ -5895,7 +5895,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1alpha1.types.SendPacketsResponse]", @@ -5971,7 +5971,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1alpha1.types.SendPacketsResponse]", @@ -6060,7 +6060,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6148,7 +6148,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6237,7 +6237,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6325,7 +6325,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6414,7 +6414,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6502,7 +6502,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6591,7 +6591,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6679,7 +6679,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6760,7 +6760,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6840,7 +6840,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6921,7 +6921,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7001,7 +7001,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7082,7 +7082,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7162,7 +7162,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7243,7 +7243,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7323,7 +7323,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7404,7 +7404,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.GenerateStreamHlsTokenResponse", @@ -7484,7 +7484,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.GenerateStreamHlsTokenResponse", @@ -7565,7 +7565,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Cluster", @@ -7645,7 +7645,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Cluster", @@ -7726,7 +7726,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Event", @@ -7806,7 +7806,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Event", @@ -7887,7 +7887,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Series", @@ -7967,7 +7967,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Series", @@ -8048,7 +8048,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Stream", @@ -8128,7 +8128,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Stream", @@ -8209,7 +8209,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListClustersAsyncPager", @@ -8289,7 +8289,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListClustersPager", @@ -8370,7 +8370,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListEventsAsyncPager", @@ -8450,7 +8450,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListEventsPager", @@ -8531,7 +8531,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListSeriesAsyncPager", @@ -8611,7 +8611,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListSeriesPager", @@ -8692,7 +8692,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListStreamsAsyncPager", @@ -8772,7 +8772,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListStreamsPager", @@ -8861,7 +8861,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -8949,7 +8949,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9034,7 +9034,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9118,7 +9118,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9203,7 +9203,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9287,7 +9287,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9372,7 +9372,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9456,7 +9456,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9541,7 +9541,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9625,7 +9625,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9702,7 +9702,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.ClipAssetResponse", @@ -9778,7 +9778,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.ClipAssetResponse", @@ -9867,7 +9867,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Annotation", @@ -9955,7 +9955,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Annotation", @@ -10044,7 +10044,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Asset", @@ -10132,7 +10132,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Asset", @@ -10217,7 +10217,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -10301,7 +10301,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -10386,7 +10386,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.DataSchema", @@ -10470,7 +10470,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.DataSchema", @@ -10559,7 +10559,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.SearchConfig", @@ -10647,7 +10647,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.SearchConfig", @@ -10728,7 +10728,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_annotation" @@ -10805,7 +10805,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_annotation" @@ -10883,7 +10883,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -10963,7 +10963,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11044,7 +11044,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_corpus" @@ -11121,7 +11121,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_corpus" @@ -11199,7 +11199,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_data_schema" @@ -11276,7 +11276,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_data_schema" @@ -11354,7 +11354,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_search_config" @@ -11431,7 +11431,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_search_config" @@ -11505,7 +11505,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.GenerateHlsUriResponse", @@ -11581,7 +11581,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.GenerateHlsUriResponse", @@ -11662,7 +11662,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Annotation", @@ -11742,7 +11742,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Annotation", @@ -11823,7 +11823,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Asset", @@ -11903,7 +11903,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Asset", @@ -11984,7 +11984,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Corpus", @@ -12064,7 +12064,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Corpus", @@ -12145,7 +12145,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.DataSchema", @@ -12225,7 +12225,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.DataSchema", @@ -12306,7 +12306,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.SearchConfig", @@ -12386,7 +12386,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.SearchConfig", @@ -12463,7 +12463,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1alpha1.types.IngestAssetResponse]", @@ -12539,7 +12539,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1alpha1.types.IngestAssetResponse]", @@ -12620,7 +12620,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListAnnotationsAsyncPager", @@ -12700,7 +12700,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListAnnotationsPager", @@ -12781,7 +12781,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListAssetsAsyncPager", @@ -12861,7 +12861,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListAssetsPager", @@ -12942,7 +12942,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListCorporaAsyncPager", @@ -13022,7 +13022,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListCorporaPager", @@ -13103,7 +13103,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListDataSchemasAsyncPager", @@ -13183,7 +13183,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListDataSchemasPager", @@ -13264,7 +13264,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListSearchConfigsAsyncPager", @@ -13344,7 +13344,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListSearchConfigsPager", @@ -13421,7 +13421,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.warehouse.pagers.SearchAssetsAsyncPager", @@ -13497,7 +13497,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.warehouse.pagers.SearchAssetsPager", @@ -13582,7 +13582,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Annotation", @@ -13666,7 +13666,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Annotation", @@ -13751,7 +13751,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Asset", @@ -13835,7 +13835,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Asset", @@ -13920,7 +13920,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Corpus", @@ -14004,7 +14004,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Corpus", @@ -14089,7 +14089,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.DataSchema", @@ -14173,7 +14173,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.DataSchema", @@ -14258,7 +14258,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.SearchConfig", @@ -14342,7 +14342,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.SearchConfig", diff --git a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_app_platform.py b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_app_platform.py index a4f2a3935988..ba5aa943954c 100644 --- a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_app_platform.py +++ b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_app_platform.py @@ -10916,6 +10916,7 @@ def test_list_applications_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_applications(request) @@ -10971,6 +10972,7 @@ def test_list_applications_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_applications(**mock_args) @@ -11163,6 +11165,7 @@ def test_get_application_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_application(request) @@ -11210,6 +11213,7 @@ def test_get_application_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_application(**mock_args) @@ -11361,6 +11365,7 @@ def test_create_application_rest_required_fields( response_value._content = json_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_application(request) @@ -11425,6 +11430,7 @@ def test_create_application_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_application(**mock_args) @@ -11565,6 +11571,7 @@ def test_update_application_rest_required_fields( response_value._content = json_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_application(request) @@ -11621,6 +11628,7 @@ def test_update_application_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_application(**mock_args) @@ -11765,6 +11773,7 @@ def test_delete_application_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_application(request) @@ -11818,6 +11827,7 @@ def test_delete_application_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_application(**mock_args) @@ -11955,6 +11965,7 @@ def test_deploy_application_rest_required_fields( response_value._content = json_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_application(request) @@ -12000,6 +12011,7 @@ def test_deploy_application_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_application(**mock_args) @@ -12137,6 +12149,7 @@ def test_undeploy_application_rest_required_fields( response_value._content = json_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_application(request) @@ -12182,6 +12195,7 @@ def test_undeploy_application_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_application(**mock_args) @@ -12320,6 +12334,7 @@ def test_add_application_stream_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.add_application_stream_input(request) @@ -12365,6 +12380,7 @@ def test_add_application_stream_input_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_application_stream_input(**mock_args) @@ -12503,6 +12519,7 @@ def test_remove_application_stream_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.remove_application_stream_input(request) @@ -12550,6 +12567,7 @@ def test_remove_application_stream_input_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_application_stream_input(**mock_args) @@ -12688,6 +12706,7 @@ def test_update_application_stream_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.update_application_stream_input(request) @@ -12735,6 +12754,7 @@ def test_update_application_stream_input_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_application_stream_input(**mock_args) @@ -12875,6 +12895,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) @@ -12932,6 +12953,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) @@ -13124,6 +13146,7 @@ def test_get_instance_rest_required_fields(request_type=platform.GetInstanceRequ response_value._content = json_return_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) @@ -13171,6 +13194,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) @@ -13309,6 +13333,7 @@ def test_create_application_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_application_instances(request) @@ -13362,6 +13387,7 @@ def test_create_application_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_application_instances(**mock_args) @@ -13504,6 +13530,7 @@ def test_delete_application_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_application_instances(request) @@ -13557,6 +13584,7 @@ def test_delete_application_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_application_instances(**mock_args) @@ -13695,6 +13723,7 @@ def test_update_application_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.update_application_instances(request) @@ -13745,6 +13774,7 @@ def test_update_application_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.update_application_instances(**mock_args) @@ -13888,6 +13918,7 @@ def test_list_drafts_rest_required_fields(request_type=platform.ListDraftsReques response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_drafts(request) @@ -13945,6 +13976,7 @@ def test_list_drafts_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_drafts(**mock_args) @@ -14137,6 +14169,7 @@ def test_get_draft_rest_required_fields(request_type=platform.GetDraftRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_draft(request) @@ -14184,6 +14217,7 @@ def test_get_draft_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_draft(**mock_args) @@ -14329,6 +14363,7 @@ def test_create_draft_rest_required_fields(request_type=platform.CreateDraftRequ response_value._content = json_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_draft(request) @@ -14396,6 +14431,7 @@ def test_create_draft_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_draft(**mock_args) @@ -14532,6 +14568,7 @@ def test_update_draft_rest_required_fields(request_type=platform.UpdateDraftRequ response_value._content = json_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_draft(request) @@ -14589,6 +14626,7 @@ def test_update_draft_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_draft(**mock_args) @@ -14722,6 +14760,7 @@ def test_delete_draft_rest_required_fields(request_type=platform.DeleteDraftRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_draft(request) @@ -14767,6 +14806,7 @@ def test_delete_draft_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_draft(**mock_args) @@ -14907,6 +14947,7 @@ def test_list_processors_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_processors(request) @@ -14962,6 +15003,7 @@ def test_list_processors_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_processors(**mock_args) @@ -15159,6 +15201,7 @@ def test_list_prebuilt_processors_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_prebuilt_processors(request) @@ -15204,6 +15247,7 @@ def test_list_prebuilt_processors_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_prebuilt_processors(**mock_args) @@ -15333,6 +15377,7 @@ def test_get_processor_rest_required_fields(request_type=platform.GetProcessorRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_processor(request) @@ -15380,6 +15425,7 @@ def test_get_processor_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_processor(**mock_args) @@ -15528,6 +15574,7 @@ def test_create_processor_rest_required_fields( response_value._content = json_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_processor(request) @@ -15593,6 +15640,7 @@ def test_create_processor_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_processor(**mock_args) @@ -15731,6 +15779,7 @@ def test_update_processor_rest_required_fields( response_value._content = json_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_processor(request) @@ -15787,6 +15836,7 @@ def test_update_processor_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_processor(**mock_args) @@ -15924,6 +15974,7 @@ def test_delete_processor_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_processor(request) @@ -15969,6 +16020,7 @@ def test_delete_processor_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_processor(**mock_args) @@ -17436,6 +17488,7 @@ def test_list_applications_rest_bad_request( response_value.status_code = 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_applications(request) @@ -17472,6 +17525,7 @@ def test_list_applications_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_applications(request) # Establish that the response is the type that we expect. @@ -17513,6 +17567,7 @@ def test_list_applications_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = platform.ListApplicationsResponse.to_json( platform.ListApplicationsResponse() ) @@ -17557,6 +17612,7 @@ def test_get_application_rest_bad_request(request_type=platform.GetApplicationRe response_value.status_code = 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_application(request) @@ -17596,6 +17652,7 @@ def test_get_application_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_application(request) # Establish that the response is the type that we expect. @@ -17638,6 +17695,7 @@ def test_get_application_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = platform.Application.to_json(platform.Application()) req.return_value.content = return_value @@ -17682,6 +17740,7 @@ def test_create_application_rest_bad_request( response_value.status_code = 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_application(request) @@ -17930,6 +17989,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_application(request) # Establish that the response is the type that we expect. @@ -17971,6 +18031,7 @@ def test_create_application_rest_interceptors(null_interceptor): req.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 @@ -18019,6 +18080,7 @@ def test_update_application_rest_bad_request( response_value.status_code = 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_application(request) @@ -18271,6 +18333,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_application(request) # Establish that the response is the type that we expect. @@ -18312,6 +18375,7 @@ def test_update_application_rest_interceptors(null_interceptor): req.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 @@ -18356,6 +18420,7 @@ def test_delete_application_rest_bad_request( response_value.status_code = 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_application(request) @@ -18386,6 +18451,7 @@ def test_delete_application_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_application(request) # Establish that the response is the type that we expect. @@ -18427,6 +18493,7 @@ def test_delete_application_rest_interceptors(null_interceptor): req.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 @@ -18471,6 +18538,7 @@ def test_deploy_application_rest_bad_request( response_value.status_code = 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_application(request) @@ -18501,6 +18569,7 @@ def test_deploy_application_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_application(request) # Establish that the response is the type that we expect. @@ -18542,6 +18611,7 @@ def test_deploy_application_rest_interceptors(null_interceptor): req.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 @@ -18586,6 +18656,7 @@ def test_undeploy_application_rest_bad_request( response_value.status_code = 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_application(request) @@ -18616,6 +18687,7 @@ def test_undeploy_application_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_application(request) # Establish that the response is the type that we expect. @@ -18657,6 +18729,7 @@ def test_undeploy_application_rest_interceptors(null_interceptor): req.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 @@ -18701,6 +18774,7 @@ def test_add_application_stream_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.add_application_stream_input(request) @@ -18731,6 +18805,7 @@ def test_add_application_stream_input_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_application_stream_input(request) # Establish that the response is the type that we expect. @@ -18772,6 +18847,7 @@ def test_add_application_stream_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -18816,6 +18892,7 @@ def test_remove_application_stream_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.remove_application_stream_input(request) @@ -18846,6 +18923,7 @@ def test_remove_application_stream_input_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_application_stream_input(request) # Establish that the response is the type that we expect. @@ -18887,6 +18965,7 @@ def test_remove_application_stream_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -18931,6 +19010,7 @@ def test_update_application_stream_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.update_application_stream_input(request) @@ -18961,6 +19041,7 @@ def test_update_application_stream_input_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_application_stream_input(request) # Establish that the response is the type that we expect. @@ -19002,6 +19083,7 @@ def test_update_application_stream_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -19044,6 +19126,7 @@ def test_list_instances_rest_bad_request(request_type=platform.ListInstancesRequ response_value.status_code = 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) @@ -19080,6 +19163,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. @@ -19119,6 +19203,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 = platform.ListInstancesResponse.to_json( platform.ListInstancesResponse() ) @@ -19165,6 +19250,7 @@ def test_get_instance_rest_bad_request(request_type=platform.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_instance(request) @@ -19206,6 +19292,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. @@ -19248,6 +19335,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 = platform.Instance.to_json(platform.Instance()) req.return_value.content = return_value @@ -19292,6 +19380,7 @@ def test_create_application_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.create_application_instances(request) @@ -19322,6 +19411,7 @@ def test_create_application_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.create_application_instances(request) # Establish that the response is the type that we expect. @@ -19363,6 +19453,7 @@ def test_create_application_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -19407,6 +19498,7 @@ def test_delete_application_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.delete_application_instances(request) @@ -19437,6 +19529,7 @@ def test_delete_application_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.delete_application_instances(request) # Establish that the response is the type that we expect. @@ -19478,6 +19571,7 @@ def test_delete_application_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -19522,6 +19616,7 @@ def test_update_application_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.update_application_instances(request) @@ -19552,6 +19647,7 @@ def test_update_application_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.update_application_instances(request) # Establish that the response is the type that we expect. @@ -19593,6 +19689,7 @@ def test_update_application_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -19635,6 +19732,7 @@ def test_list_drafts_rest_bad_request(request_type=platform.ListDraftsRequest): response_value.status_code = 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_drafts(request) @@ -19671,6 +19769,7 @@ def test_list_drafts_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_drafts(request) # Establish that the response is the type that we expect. @@ -19710,6 +19809,7 @@ def test_list_drafts_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = platform.ListDraftsResponse.to_json( platform.ListDraftsResponse() ) @@ -19756,6 +19856,7 @@ def test_get_draft_rest_bad_request(request_type=platform.GetDraftRequest): response_value.status_code = 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_draft(request) @@ -19795,6 +19896,7 @@ def test_get_draft_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_draft(request) # Establish that the response is the type that we expect. @@ -19835,6 +19937,7 @@ def test_get_draft_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = platform.Draft.to_json(platform.Draft()) req.return_value.content = return_value @@ -19877,6 +19980,7 @@ def test_create_draft_rest_bad_request(request_type=platform.CreateDraftRequest) response_value.status_code = 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_draft(request) @@ -20112,6 +20216,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_draft(request) # Establish that the response is the type that we expect. @@ -20151,6 +20256,7 @@ def test_create_draft_rest_interceptors(null_interceptor): req.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 @@ -20197,6 +20303,7 @@ def test_update_draft_rest_bad_request(request_type=platform.UpdateDraftRequest) response_value.status_code = 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_draft(request) @@ -20436,6 +20543,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_draft(request) # Establish that the response is the type that we expect. @@ -20475,6 +20583,7 @@ def test_update_draft_rest_interceptors(null_interceptor): req.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 @@ -20519,6 +20628,7 @@ def test_delete_draft_rest_bad_request(request_type=platform.DeleteDraftRequest) response_value.status_code = 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_draft(request) @@ -20551,6 +20661,7 @@ def test_delete_draft_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_draft(request) # Establish that the response is the type that we expect. @@ -20590,6 +20701,7 @@ def test_delete_draft_rest_interceptors(null_interceptor): req.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 @@ -20632,6 +20744,7 @@ def test_list_processors_rest_bad_request(request_type=platform.ListProcessorsRe response_value.status_code = 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_processors(request) @@ -20668,6 +20781,7 @@ def test_list_processors_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_processors(request) # Establish that the response is the type that we expect. @@ -20707,6 +20821,7 @@ def test_list_processors_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = platform.ListProcessorsResponse.to_json( platform.ListProcessorsResponse() ) @@ -20753,6 +20868,7 @@ def test_list_prebuilt_processors_rest_bad_request( response_value.status_code = 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_prebuilt_processors(request) @@ -20786,6 +20902,7 @@ def test_list_prebuilt_processors_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_prebuilt_processors(request) # Establish that the response is the type that we expect. @@ -20825,6 +20942,7 @@ def test_list_prebuilt_processors_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = platform.ListPrebuiltProcessorsResponse.to_json( platform.ListPrebuiltProcessorsResponse() ) @@ -20869,6 +20987,7 @@ def test_get_processor_rest_bad_request(request_type=platform.GetProcessorReques response_value.status_code = 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_processor(request) @@ -20917,6 +21036,7 @@ def test_get_processor_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_processor(request) # Establish that the response is the type that we expect. @@ -20968,6 +21088,7 @@ def test_get_processor_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = platform.Processor.to_json(platform.Processor()) req.return_value.content = return_value @@ -21012,6 +21133,7 @@ def test_create_processor_rest_bad_request( response_value.status_code = 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_processor(request) @@ -21173,6 +21295,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_processor(request) # Establish that the response is the type that we expect. @@ -21214,6 +21337,7 @@ def test_create_processor_rest_interceptors(null_interceptor): req.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 @@ -21260,6 +21384,7 @@ def test_update_processor_rest_bad_request( response_value.status_code = 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_processor(request) @@ -21423,6 +21548,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_processor(request) # Establish that the response is the type that we expect. @@ -21464,6 +21590,7 @@ def test_update_processor_rest_interceptors(null_interceptor): req.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 @@ -21508,6 +21635,7 @@ def test_delete_processor_rest_bad_request( response_value.status_code = 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_processor(request) @@ -21538,6 +21666,7 @@ def test_delete_processor_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_processor(request) # Establish that the response is the type that we expect. @@ -21579,6 +21708,7 @@ def test_delete_processor_rest_interceptors(null_interceptor): req.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 @@ -21625,6 +21755,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) @@ -21655,6 +21786,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) @@ -21685,6 +21817,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) @@ -21715,6 +21848,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) @@ -21745,6 +21879,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) @@ -21775,6 +21910,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) @@ -21805,6 +21941,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) @@ -21835,6 +21972,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-visionai/tests/unit/gapic/visionai_v1/test_health_check_service.py b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_health_check_service.py index 34a0899a352f..f5e23a74b0a9 100644 --- a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_health_check_service.py +++ b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_health_check_service.py @@ -1582,6 +1582,7 @@ def test_health_check_rest_bad_request(request_type=health_service.HealthCheckRe response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.health_check(request) @@ -1618,6 +1619,7 @@ def test_health_check_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.health_check(request) # Establish that the response is the type that we expect. @@ -1659,6 +1661,7 @@ def test_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 = health_service.HealthCheckResponse.to_json( health_service.HealthCheckResponse() ) @@ -1707,6 +1710,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) @@ -1737,6 +1741,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) @@ -1767,6 +1772,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) @@ -1797,6 +1803,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) @@ -1827,6 +1834,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) @@ -1857,6 +1865,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) @@ -1887,6 +1896,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) @@ -1917,6 +1927,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-visionai/tests/unit/gapic/visionai_v1/test_live_video_analytics.py b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_live_video_analytics.py index 6c6bab1fa57e..c6edd81d5f4a 100644 --- a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_live_video_analytics.py +++ b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_live_video_analytics.py @@ -8119,6 +8119,7 @@ def test_list_public_operators_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_public_operators(request) @@ -8174,6 +8175,7 @@ def test_list_public_operators_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_public_operators(**mock_args) @@ -8374,6 +8376,7 @@ def test_resolve_operator_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.resolve_operator_info(request) @@ -8428,6 +8431,7 @@ def test_resolve_operator_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.resolve_operator_info(**mock_args) @@ -8569,6 +8573,7 @@ def test_list_operators_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_operators(request) @@ -8624,6 +8629,7 @@ def test_list_operators_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_operators(**mock_args) @@ -8813,6 +8819,7 @@ def test_get_operator_rest_required_fields(request_type=lva_service.GetOperatorR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_operator(request) @@ -8860,6 +8867,7 @@ def test_get_operator_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_operator(**mock_args) @@ -9006,6 +9014,7 @@ def test_create_operator_rest_required_fields( response_value._content = json_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_operator(request) @@ -9071,6 +9080,7 @@ def test_create_operator_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_operator(**mock_args) @@ -9207,6 +9217,7 @@ def test_update_operator_rest_required_fields( response_value._content = json_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_operator(request) @@ -9266,6 +9277,7 @@ def test_update_operator_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_operator(**mock_args) @@ -9401,6 +9413,7 @@ def test_delete_operator_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_operator(request) @@ -9446,6 +9459,7 @@ def test_delete_operator_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_operator(**mock_args) @@ -9585,6 +9599,7 @@ def test_list_analyses_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_analyses(request) @@ -9642,6 +9657,7 @@ def test_list_analyses_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_analyses(**mock_args) @@ -9834,6 +9850,7 @@ def test_get_analysis_rest_required_fields(request_type=lva_service.GetAnalysisR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_analysis(request) @@ -9881,6 +9898,7 @@ def test_get_analysis_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_analysis(**mock_args) @@ -10028,6 +10046,7 @@ def test_create_analysis_rest_required_fields( response_value._content = json_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_analysis(request) @@ -10095,6 +10114,7 @@ def test_create_analysis_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_analysis(**mock_args) @@ -10232,6 +10252,7 @@ def test_update_analysis_rest_required_fields( response_value._content = json_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_analysis(request) @@ -10293,6 +10314,7 @@ def test_update_analysis_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_analysis(**mock_args) @@ -10428,6 +10450,7 @@ def test_delete_analysis_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_analysis(request) @@ -10473,6 +10496,7 @@ def test_delete_analysis_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_analysis(**mock_args) @@ -10613,6 +10637,7 @@ def test_list_processes_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_processes(request) @@ -10670,6 +10695,7 @@ def test_list_processes_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_processes(**mock_args) @@ -10862,6 +10888,7 @@ def test_get_process_rest_required_fields(request_type=lva_service.GetProcessReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_process(request) @@ -10909,6 +10936,7 @@ def test_get_process_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_process(**mock_args) @@ -11056,6 +11084,7 @@ def test_create_process_rest_required_fields( response_value._content = json_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_process(request) @@ -11123,6 +11152,7 @@ def test_create_process_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_process(**mock_args) @@ -11260,6 +11290,7 @@ def test_update_process_rest_required_fields( response_value._content = json_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_process(request) @@ -11321,6 +11352,7 @@ def test_update_process_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_process(**mock_args) @@ -11456,6 +11488,7 @@ def test_delete_process_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_process(request) @@ -11501,6 +11534,7 @@ def test_delete_process_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_process(**mock_args) @@ -11636,6 +11670,7 @@ def test_batch_run_process_rest_required_fields( response_value._content = json_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_run_process(request) @@ -11690,6 +11725,7 @@ def test_batch_run_process_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_run_process(**mock_args) @@ -12733,6 +12769,7 @@ def test_list_public_operators_rest_bad_request( response_value.status_code = 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_public_operators(request) @@ -12768,6 +12805,7 @@ def test_list_public_operators_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_public_operators(request) # Establish that the response is the type that we expect. @@ -12808,6 +12846,7 @@ def test_list_public_operators_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = lva_service.ListPublicOperatorsResponse.to_json( lva_service.ListPublicOperatorsResponse() ) @@ -12854,6 +12893,7 @@ def test_resolve_operator_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.resolve_operator_info(request) @@ -12887,6 +12927,7 @@ def test_resolve_operator_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.resolve_operator_info(request) # Establish that the response is the type that we expect. @@ -12926,6 +12967,7 @@ def test_resolve_operator_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 = lva_service.ResolveOperatorInfoResponse.to_json( lva_service.ResolveOperatorInfoResponse() ) @@ -12970,6 +13012,7 @@ def test_list_operators_rest_bad_request(request_type=lva_service.ListOperatorsR response_value.status_code = 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_operators(request) @@ -13006,6 +13049,7 @@ def test_list_operators_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_operators(request) # Establish that the response is the type that we expect. @@ -13047,6 +13091,7 @@ def test_list_operators_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = lva_service.ListOperatorsResponse.to_json( lva_service.ListOperatorsResponse() ) @@ -13091,6 +13136,7 @@ def test_get_operator_rest_bad_request(request_type=lva_service.GetOperatorReque response_value.status_code = 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_operator(request) @@ -13127,6 +13173,7 @@ def test_get_operator_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_operator(request) # Establish that the response is the type that we expect. @@ -13166,6 +13213,7 @@ def test_get_operator_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = lva_resources.Operator.to_json(lva_resources.Operator()) req.return_value.content = return_value @@ -13210,6 +13258,7 @@ def test_create_operator_rest_bad_request( response_value.status_code = 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_operator(request) @@ -13341,6 +13390,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_operator(request) # Establish that the response is the type that we expect. @@ -13382,6 +13432,7 @@ def test_create_operator_rest_interceptors(null_interceptor): req.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 @@ -13428,6 +13479,7 @@ def test_update_operator_rest_bad_request( response_value.status_code = 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_operator(request) @@ -13561,6 +13613,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_operator(request) # Establish that the response is the type that we expect. @@ -13602,6 +13655,7 @@ def test_update_operator_rest_interceptors(null_interceptor): req.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 @@ -13646,6 +13700,7 @@ def test_delete_operator_rest_bad_request( response_value.status_code = 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_operator(request) @@ -13676,6 +13731,7 @@ def test_delete_operator_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_operator(request) # Establish that the response is the type that we expect. @@ -13717,6 +13773,7 @@ def test_delete_operator_rest_interceptors(null_interceptor): req.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 @@ -13759,6 +13816,7 @@ def test_list_analyses_rest_bad_request(request_type=lva_service.ListAnalysesReq response_value.status_code = 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_analyses(request) @@ -13795,6 +13853,7 @@ def test_list_analyses_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_analyses(request) # Establish that the response is the type that we expect. @@ -13836,6 +13895,7 @@ def test_list_analyses_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = lva_service.ListAnalysesResponse.to_json( lva_service.ListAnalysesResponse() ) @@ -13882,6 +13942,7 @@ def test_get_analysis_rest_bad_request(request_type=lva_service.GetAnalysisReque response_value.status_code = 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_analysis(request) @@ -13920,6 +13981,7 @@ def test_get_analysis_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_analysis(request) # Establish that the response is the type that we expect. @@ -13959,6 +14021,7 @@ def test_get_analysis_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = lva_resources.Analysis.to_json(lva_resources.Analysis()) req.return_value.content = return_value @@ -14003,6 +14066,7 @@ def test_create_analysis_rest_bad_request( response_value.status_code = 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_analysis(request) @@ -14124,6 +14188,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_analysis(request) # Establish that the response is the type that we expect. @@ -14165,6 +14230,7 @@ def test_create_analysis_rest_interceptors(null_interceptor): req.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 @@ -14213,6 +14279,7 @@ def test_update_analysis_rest_bad_request( response_value.status_code = 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_analysis(request) @@ -14338,6 +14405,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_analysis(request) # Establish that the response is the type that we expect. @@ -14379,6 +14447,7 @@ def test_update_analysis_rest_interceptors(null_interceptor): req.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 @@ -14425,6 +14494,7 @@ def test_delete_analysis_rest_bad_request( response_value.status_code = 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_analysis(request) @@ -14457,6 +14527,7 @@ def test_delete_analysis_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_analysis(request) # Establish that the response is the type that we expect. @@ -14498,6 +14569,7 @@ def test_delete_analysis_rest_interceptors(null_interceptor): req.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 @@ -14540,6 +14612,7 @@ def test_list_processes_rest_bad_request(request_type=lva_service.ListProcessesR response_value.status_code = 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_processes(request) @@ -14576,6 +14649,7 @@ def test_list_processes_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_processes(request) # Establish that the response is the type that we expect. @@ -14617,6 +14691,7 @@ def test_list_processes_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = lva_service.ListProcessesResponse.to_json( lva_service.ListProcessesResponse() ) @@ -14663,6 +14738,7 @@ def test_get_process_rest_bad_request(request_type=lva_service.GetProcessRequest response_value.status_code = 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_process(request) @@ -14706,6 +14782,7 @@ def test_get_process_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_process(request) # Establish that the response is the type that we expect. @@ -14750,6 +14827,7 @@ def test_get_process_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = lva_resources.Process.to_json(lva_resources.Process()) req.return_value.content = return_value @@ -14792,6 +14870,7 @@ def test_create_process_rest_bad_request(request_type=lva_service.CreateProcessR response_value.status_code = 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_process(request) @@ -14904,6 +14983,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_process(request) # Establish that the response is the type that we expect. @@ -14945,6 +15025,7 @@ def test_create_process_rest_interceptors(null_interceptor): req.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 @@ -14991,6 +15072,7 @@ def test_update_process_rest_bad_request(request_type=lva_service.UpdateProcessR response_value.status_code = 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_process(request) @@ -15107,6 +15189,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_process(request) # Establish that the response is the type that we expect. @@ -15148,6 +15231,7 @@ def test_update_process_rest_interceptors(null_interceptor): req.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 @@ -15192,6 +15276,7 @@ def test_delete_process_rest_bad_request(request_type=lva_service.DeleteProcessR response_value.status_code = 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_process(request) @@ -15224,6 +15309,7 @@ def test_delete_process_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_process(request) # Establish that the response is the type that we expect. @@ -15265,6 +15351,7 @@ def test_delete_process_rest_interceptors(null_interceptor): req.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 @@ -15309,6 +15396,7 @@ def test_batch_run_process_rest_bad_request( response_value.status_code = 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_run_process(request) @@ -15339,6 +15427,7 @@ def test_batch_run_process_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_run_process(request) # Establish that the response is the type that we expect. @@ -15380,6 +15469,7 @@ def test_batch_run_process_rest_interceptors(null_interceptor): req.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 @@ -15426,6 +15516,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) @@ -15456,6 +15547,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) @@ -15486,6 +15578,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) @@ -15516,6 +15609,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) @@ -15546,6 +15640,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) @@ -15576,6 +15671,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) @@ -15606,6 +15702,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) @@ -15636,6 +15733,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-visionai/tests/unit/gapic/visionai_v1/test_streaming_service.py b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_streaming_service.py index 62269285098d..b8b8816d3d45 100644 --- a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_streaming_service.py +++ b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_streaming_service.py @@ -2810,6 +2810,7 @@ def test_acquire_lease_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.acquire_lease(request) @@ -2850,6 +2851,7 @@ def test_acquire_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.acquire_lease(request) # Establish that the response is the type that we expect. @@ -2893,6 +2895,7 @@ def test_acquire_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 = streaming_service.Lease.to_json(streaming_service.Lease()) req.return_value.content = return_value @@ -2937,6 +2940,7 @@ def test_renew_lease_rest_bad_request(request_type=streaming_service.RenewLeaseR response_value.status_code = 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) @@ -2977,6 +2981,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. @@ -3020,6 +3025,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 = streaming_service.Lease.to_json(streaming_service.Lease()) req.return_value.content = return_value @@ -3066,6 +3072,7 @@ def test_release_lease_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.release_lease(request) @@ -3101,6 +3108,7 @@ def test_release_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.release_lease(request) # Establish that the response is the type that we expect. @@ -3140,6 +3148,7 @@ def test_release_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 = streaming_service.ReleaseLeaseResponse.to_json( streaming_service.ReleaseLeaseResponse() ) @@ -3188,6 +3197,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) @@ -3218,6 +3228,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) @@ -3248,6 +3259,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) @@ -3278,6 +3290,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) @@ -3308,6 +3321,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) @@ -3338,6 +3352,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) @@ -3368,6 +3383,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) @@ -3398,6 +3414,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-visionai/tests/unit/gapic/visionai_v1/test_streams_service.py b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_streams_service.py index 06dc3aa187db..eca3241f3257 100644 --- a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_streams_service.py +++ b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_streams_service.py @@ -9758,6 +9758,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) @@ -9813,6 +9814,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) @@ -10006,6 +10008,7 @@ def test_get_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_cluster(request) @@ -10051,6 +10054,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) @@ -10197,6 +10201,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) @@ -10262,6 +10267,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) @@ -10398,6 +10404,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) @@ -10457,6 +10464,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) @@ -10592,6 +10600,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) @@ -10635,6 +10644,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) @@ -10774,6 +10784,7 @@ def test_list_streams_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_streams(request) @@ -10831,6 +10842,7 @@ def test_list_streams_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_streams(**mock_args) @@ -11025,6 +11037,7 @@ def test_get_stream_rest_required_fields(request_type=streams_service.GetStreamR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_stream(request) @@ -11072,6 +11085,7 @@ def test_get_stream_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_stream(**mock_args) @@ -11219,6 +11233,7 @@ def test_create_stream_rest_required_fields( response_value._content = json_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_stream(request) @@ -11286,6 +11301,7 @@ def test_create_stream_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_stream(**mock_args) @@ -11423,6 +11439,7 @@ def test_update_stream_rest_required_fields( response_value._content = json_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_stream(request) @@ -11484,6 +11501,7 @@ def test_update_stream_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_stream(**mock_args) @@ -11619,6 +11637,7 @@ def test_delete_stream_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_stream(request) @@ -11664,6 +11683,7 @@ def test_delete_stream_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_stream(**mock_args) @@ -11805,6 +11825,7 @@ def test_get_stream_thumbnail_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_stream_thumbnail(request) @@ -11859,6 +11880,7 @@ def test_get_stream_thumbnail_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_stream_thumbnail(**mock_args) @@ -11999,6 +12021,7 @@ def test_generate_stream_hls_token_rest_required_fields( response_value._content = json_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_stream_hls_token(request) @@ -12046,6 +12069,7 @@ def test_generate_stream_hls_token_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_stream_hls_token(**mock_args) @@ -12186,6 +12210,7 @@ def test_list_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_events(request) @@ -12243,6 +12268,7 @@ def test_list_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_events(**mock_args) @@ -12437,6 +12463,7 @@ def test_get_event_rest_required_fields(request_type=streams_service.GetEventReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_event(request) @@ -12484,6 +12511,7 @@ def test_get_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_event(**mock_args) @@ -12631,6 +12659,7 @@ def test_create_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.create_event(request) @@ -12698,6 +12727,7 @@ def test_create_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.create_event(**mock_args) @@ -12835,6 +12865,7 @@ def test_update_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.update_event(request) @@ -12896,6 +12927,7 @@ def test_update_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.update_event(**mock_args) @@ -13031,6 +13063,7 @@ def test_delete_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.delete_event(request) @@ -13076,6 +13109,7 @@ def test_delete_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.delete_event(**mock_args) @@ -13216,6 +13250,7 @@ def test_list_series_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_series(request) @@ -13273,6 +13308,7 @@ def test_list_series_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_series(**mock_args) @@ -13467,6 +13503,7 @@ def test_get_series_rest_required_fields(request_type=streams_service.GetSeriesR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_series(request) @@ -13514,6 +13551,7 @@ def test_get_series_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_series(**mock_args) @@ -13661,6 +13699,7 @@ def test_create_series_rest_required_fields( response_value._content = json_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_series(request) @@ -13728,6 +13767,7 @@ def test_create_series_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_series(**mock_args) @@ -13865,6 +13905,7 @@ def test_update_series_rest_required_fields( response_value._content = json_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_series(request) @@ -13926,6 +13967,7 @@ def test_update_series_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_series(**mock_args) @@ -14061,6 +14103,7 @@ def test_delete_series_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_series(request) @@ -14106,6 +14149,7 @@ def test_delete_series_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_series(**mock_args) @@ -14257,6 +14301,7 @@ def test_materialize_channel_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.materialize_channel(request) @@ -14324,6 +14369,7 @@ def test_materialize_channel_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.materialize_channel(**mock_args) @@ -15604,6 +15650,7 @@ def test_list_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_clusters(request) @@ -15640,6 +15687,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. @@ -15681,6 +15729,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 = streams_service.ListClustersResponse.to_json( streams_service.ListClustersResponse() ) @@ -15725,6 +15774,7 @@ def test_get_cluster_rest_bad_request(request_type=streams_service.GetClusterReq response_value.status_code = 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) @@ -15763,6 +15813,7 @@ 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. @@ -15806,6 +15857,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 = common.Cluster.to_json(common.Cluster()) req.return_value.content = return_value @@ -15850,6 +15902,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) @@ -15957,6 +16010,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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. @@ -15998,6 +16052,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 @@ -16044,6 +16099,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) @@ -16153,6 +16209,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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. @@ -16194,6 +16251,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 @@ -16238,6 +16296,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) @@ -16268,6 +16327,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. @@ -16309,6 +16369,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 @@ -16351,6 +16412,7 @@ def test_list_streams_rest_bad_request(request_type=streams_service.ListStreamsR response_value.status_code = 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_streams(request) @@ -16387,6 +16449,7 @@ def test_list_streams_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_streams(request) # Establish that the response is the type that we expect. @@ -16428,6 +16491,7 @@ def test_list_streams_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = streams_service.ListStreamsResponse.to_json( streams_service.ListStreamsResponse() ) @@ -16474,6 +16538,7 @@ def test_get_stream_rest_bad_request(request_type=streams_service.GetStreamReque response_value.status_code = 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_stream(request) @@ -16514,6 +16579,7 @@ def test_get_stream_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_stream(request) # Establish that the response is the type that we expect. @@ -16557,6 +16623,7 @@ def test_get_stream_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = streams_resources.Stream.to_json(streams_resources.Stream()) req.return_value.content = return_value @@ -16601,6 +16668,7 @@ def test_create_stream_rest_bad_request( response_value.status_code = 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_stream(request) @@ -16708,6 +16776,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_stream(request) # Establish that the response is the type that we expect. @@ -16749,6 +16818,7 @@ def test_create_stream_rest_interceptors(null_interceptor): req.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 @@ -16797,6 +16867,7 @@ def test_update_stream_rest_bad_request( response_value.status_code = 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_stream(request) @@ -16908,6 +16979,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_stream(request) # Establish that the response is the type that we expect. @@ -16949,6 +17021,7 @@ def test_update_stream_rest_interceptors(null_interceptor): req.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 @@ -16995,6 +17068,7 @@ def test_delete_stream_rest_bad_request( response_value.status_code = 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_stream(request) @@ -17027,6 +17101,7 @@ def test_delete_stream_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_stream(request) # Establish that the response is the type that we expect. @@ -17068,6 +17143,7 @@ def test_delete_stream_rest_interceptors(null_interceptor): req.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 @@ -17114,6 +17190,7 @@ def test_get_stream_thumbnail_rest_bad_request( response_value.status_code = 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_stream_thumbnail(request) @@ -17146,6 +17223,7 @@ def test_get_stream_thumbnail_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_stream_thumbnail(request) # Establish that the response is the type that we expect. @@ -17187,6 +17265,7 @@ def test_get_stream_thumbnail_rest_interceptors(null_interceptor): req.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 @@ -17233,6 +17312,7 @@ def test_generate_stream_hls_token_rest_bad_request( response_value.status_code = 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_stream_hls_token(request) @@ -17270,6 +17350,7 @@ def test_generate_stream_hls_token_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_stream_hls_token(request) # Establish that the response is the type that we expect. @@ -17310,6 +17391,7 @@ def test_generate_stream_hls_token_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = streams_service.GenerateStreamHlsTokenResponse.to_json( streams_service.GenerateStreamHlsTokenResponse() ) @@ -17354,6 +17436,7 @@ def test_list_events_rest_bad_request(request_type=streams_service.ListEventsReq response_value.status_code = 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_events(request) @@ -17390,6 +17473,7 @@ def test_list_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_events(request) # Establish that the response is the type that we expect. @@ -17431,6 +17515,7 @@ def test_list_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 = streams_service.ListEventsResponse.to_json( streams_service.ListEventsResponse() ) @@ -17477,6 +17562,7 @@ def test_get_event_rest_bad_request(request_type=streams_service.GetEventRequest response_value.status_code = 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_event(request) @@ -17515,6 +17601,7 @@ def test_get_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_event(request) # Establish that the response is the type that we expect. @@ -17556,6 +17643,7 @@ def test_get_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 = streams_resources.Event.to_json(streams_resources.Event()) req.return_value.content = return_value @@ -17598,6 +17686,7 @@ def test_create_event_rest_bad_request(request_type=streams_service.CreateEventR response_value.status_code = 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_event(request) @@ -17704,6 +17793,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_event(request) # Establish that the response is the type that we expect. @@ -17745,6 +17835,7 @@ def test_create_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -17791,6 +17882,7 @@ def test_update_event_rest_bad_request(request_type=streams_service.UpdateEventR response_value.status_code = 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_event(request) @@ -17901,6 +17993,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_event(request) # Establish that the response is the type that we expect. @@ -17942,6 +18035,7 @@ def test_update_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -17986,6 +18080,7 @@ def test_delete_event_rest_bad_request(request_type=streams_service.DeleteEventR response_value.status_code = 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_event(request) @@ -18018,6 +18113,7 @@ def test_delete_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.delete_event(request) # Establish that the response is the type that we expect. @@ -18059,6 +18155,7 @@ def test_delete_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -18101,6 +18198,7 @@ def test_list_series_rest_bad_request(request_type=streams_service.ListSeriesReq response_value.status_code = 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_series(request) @@ -18137,6 +18235,7 @@ def test_list_series_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_series(request) # Establish that the response is the type that we expect. @@ -18178,6 +18277,7 @@ def test_list_series_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = streams_service.ListSeriesResponse.to_json( streams_service.ListSeriesResponse() ) @@ -18224,6 +18324,7 @@ def test_get_series_rest_bad_request(request_type=streams_service.GetSeriesReque response_value.status_code = 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_series(request) @@ -18263,6 +18364,7 @@ def test_get_series_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_series(request) # Establish that the response is the type that we expect. @@ -18305,6 +18407,7 @@ def test_get_series_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = streams_resources.Series.to_json(streams_resources.Series()) req.return_value.content = return_value @@ -18349,6 +18452,7 @@ def test_create_series_rest_bad_request( response_value.status_code = 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_series(request) @@ -18455,6 +18559,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_series(request) # Establish that the response is the type that we expect. @@ -18496,6 +18601,7 @@ def test_create_series_rest_interceptors(null_interceptor): req.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 @@ -18544,6 +18650,7 @@ def test_update_series_rest_bad_request( response_value.status_code = 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_series(request) @@ -18654,6 +18761,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_series(request) # Establish that the response is the type that we expect. @@ -18695,6 +18803,7 @@ def test_update_series_rest_interceptors(null_interceptor): req.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 @@ -18741,6 +18850,7 @@ def test_delete_series_rest_bad_request( response_value.status_code = 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_series(request) @@ -18773,6 +18883,7 @@ def test_delete_series_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_series(request) # Establish that the response is the type that we expect. @@ -18814,6 +18925,7 @@ def test_delete_series_rest_interceptors(null_interceptor): req.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 @@ -18858,6 +18970,7 @@ def test_materialize_channel_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.materialize_channel(request) @@ -18964,6 +19077,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.materialize_channel(request) # Establish that the response is the type that we expect. @@ -19005,6 +19119,7 @@ def test_materialize_channel_rest_interceptors(null_interceptor): req.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 @@ -19051,6 +19166,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) @@ -19081,6 +19197,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) @@ -19111,6 +19228,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) @@ -19141,6 +19259,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) @@ -19171,6 +19290,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) @@ -19201,6 +19321,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) @@ -19231,6 +19352,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) @@ -19261,6 +19383,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-visionai/tests/unit/gapic/visionai_v1/test_warehouse.py b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_warehouse.py index 2752c79dc795..dc4f95362624 100644 --- a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_warehouse.py +++ b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_warehouse.py @@ -23752,6 +23752,7 @@ def test_create_asset_rest_required_fields(request_type=warehouse.CreateAssetReq response_value._content = json_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_asset(request) @@ -23809,6 +23810,7 @@ def test_create_asset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_asset(**mock_args) @@ -23938,6 +23940,7 @@ def test_update_asset_rest_required_fields(request_type=warehouse.UpdateAssetReq response_value._content = json_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_asset(request) @@ -23988,6 +23991,7 @@ def test_update_asset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_asset(**mock_args) @@ -24118,6 +24122,7 @@ def test_get_asset_rest_required_fields(request_type=warehouse.GetAssetRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_asset(request) @@ -24165,6 +24170,7 @@ def test_get_asset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_asset(**mock_args) @@ -24302,6 +24308,7 @@ def test_list_assets_rest_required_fields(request_type=warehouse.ListAssetsReque response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_assets(request) @@ -24358,6 +24365,7 @@ def test_list_assets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_assets(**mock_args) @@ -24551,6 +24559,7 @@ def test_delete_asset_rest_required_fields(request_type=warehouse.DeleteAssetReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_asset(request) @@ -24596,6 +24605,7 @@ def test_delete_asset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_asset(**mock_args) @@ -24727,6 +24737,7 @@ def test_upload_asset_rest_required_fields(request_type=warehouse.UploadAssetReq response_value._content = json_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_asset(request) @@ -24852,6 +24863,7 @@ def test_generate_retrieval_url_rest_required_fields( response_value._content = json_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_retrieval_url(request) @@ -24971,6 +24983,7 @@ def test_analyze_asset_rest_required_fields(request_type=warehouse.AnalyzeAssetR response_value._content = json_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_asset(request) @@ -25090,6 +25103,7 @@ def test_index_asset_rest_required_fields(request_type=warehouse.IndexAssetReque response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.index_asset(request) @@ -25215,6 +25229,7 @@ def test_remove_index_asset_rest_required_fields( response_value._content = json_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_index_asset(request) @@ -25346,6 +25361,7 @@ def test_view_indexed_assets_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.view_indexed_assets(request) @@ -25402,6 +25418,7 @@ def test_view_indexed_assets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.view_indexed_assets(**mock_args) @@ -25600,6 +25617,7 @@ def test_create_index_rest_required_fields(request_type=warehouse.CreateIndexReq response_value._content = json_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_index(request) @@ -25655,6 +25673,7 @@ def test_create_index_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_index(**mock_args) @@ -25785,6 +25804,7 @@ def test_update_index_rest_required_fields(request_type=warehouse.UpdateIndexReq response_value._content = json_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_index(request) @@ -25841,6 +25861,7 @@ def test_update_index_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_index(**mock_args) @@ -25971,6 +25992,7 @@ def test_get_index_rest_required_fields(request_type=warehouse.GetIndexRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_index(request) @@ -26018,6 +26040,7 @@ def test_get_index_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_index(**mock_args) @@ -26154,6 +26177,7 @@ def test_list_indexes_rest_required_fields(request_type=warehouse.ListIndexesReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_indexes(request) @@ -26209,6 +26233,7 @@ def test_list_indexes_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_indexes(**mock_args) @@ -26402,6 +26427,7 @@ def test_delete_index_rest_required_fields(request_type=warehouse.DeleteIndexReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_index(request) @@ -26447,6 +26473,7 @@ def test_delete_index_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_index(**mock_args) @@ -26578,6 +26605,7 @@ def test_create_corpus_rest_required_fields(request_type=warehouse.CreateCorpusR response_value._content = json_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_corpus(request) @@ -26630,6 +26658,7 @@ def test_create_corpus_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_corpus(**mock_args) @@ -26759,6 +26788,7 @@ def test_get_corpus_rest_required_fields(request_type=warehouse.GetCorpusRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_corpus(request) @@ -26804,6 +26834,7 @@ def test_get_corpus_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_corpus(**mock_args) @@ -26930,6 +26961,7 @@ def test_update_corpus_rest_required_fields(request_type=warehouse.UpdateCorpusR response_value._content = json_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_corpus(request) @@ -26978,6 +27010,7 @@ def test_update_corpus_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_corpus(**mock_args) @@ -27116,6 +27149,7 @@ def test_list_corpora_rest_required_fields(request_type=warehouse.ListCorporaReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_corpora(request) @@ -27170,6 +27204,7 @@ def test_list_corpora_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_corpora(**mock_args) @@ -27356,6 +27391,7 @@ def test_delete_corpus_rest_required_fields(request_type=warehouse.DeleteCorpusR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_corpus(request) @@ -27399,6 +27435,7 @@ def test_delete_corpus_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_corpus(**mock_args) @@ -27531,6 +27568,7 @@ def test_analyze_corpus_rest_required_fields( response_value._content = json_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_corpus(request) @@ -27655,6 +27693,7 @@ def test_create_data_schema_rest_required_fields( response_value._content = json_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_data_schema(request) @@ -27711,6 +27750,7 @@ def test_create_data_schema_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_data_schema(**mock_args) @@ -27845,6 +27885,7 @@ def test_update_data_schema_rest_required_fields( response_value._content = json_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_data_schema(request) @@ -27895,6 +27936,7 @@ def test_update_data_schema_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_data_schema(**mock_args) @@ -28027,6 +28069,7 @@ def test_get_data_schema_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_data_schema(request) @@ -28074,6 +28117,7 @@ def test_get_data_schema_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_data_schema(**mock_args) @@ -28206,6 +28250,7 @@ def test_delete_data_schema_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_data_schema(request) @@ -28251,6 +28296,7 @@ def test_delete_data_schema_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_data_schema(**mock_args) @@ -28391,6 +28437,7 @@ def test_list_data_schemas_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_data_schemas(request) @@ -28446,6 +28493,7 @@ def test_list_data_schemas_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_data_schemas(**mock_args) @@ -28645,6 +28693,7 @@ def test_create_annotation_rest_required_fields( response_value._content = json_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_annotation(request) @@ -28702,6 +28751,7 @@ def test_create_annotation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_annotation(**mock_args) @@ -28835,6 +28885,7 @@ def test_get_annotation_rest_required_fields( response_value._content = json_return_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(request) @@ -28882,6 +28933,7 @@ def test_get_annotation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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(**mock_args) @@ -28979,6 +29031,7 @@ def test_list_annotations_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_annotations(**mock_args) @@ -29173,6 +29226,7 @@ def test_update_annotation_rest_required_fields( response_value._content = json_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_annotation(request) @@ -29223,6 +29277,7 @@ def test_update_annotation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_annotation(**mock_args) @@ -29354,6 +29409,7 @@ def test_delete_annotation_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_annotation(request) @@ -29399,6 +29455,7 @@ def test_delete_annotation_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_annotation(**mock_args) @@ -29540,6 +29597,7 @@ def test_clip_asset_rest_required_fields(request_type=warehouse.ClipAssetRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.clip_asset(request) @@ -29670,6 +29728,7 @@ def test_generate_hls_uri_rest_required_fields( response_value._content = json_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_hls_uri(request) @@ -29789,6 +29848,7 @@ def test_import_assets_rest_required_fields(request_type=warehouse.ImportAssetsR response_value._content = json_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_assets(request) @@ -29922,6 +29982,7 @@ def test_create_search_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_search_config(request) @@ -29986,6 +30047,7 @@ def test_create_search_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_search_config(**mock_args) @@ -30121,6 +30183,7 @@ def test_update_search_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_search_config(request) @@ -30171,6 +30234,7 @@ def test_update_search_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_search_config(**mock_args) @@ -30305,6 +30369,7 @@ def test_get_search_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_search_config(request) @@ -30352,6 +30417,7 @@ def test_get_search_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_search_config(**mock_args) @@ -30484,6 +30550,7 @@ def test_delete_search_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_search_config(request) @@ -30529,6 +30596,7 @@ def test_delete_search_config_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_search_config(**mock_args) @@ -30671,6 +30739,7 @@ def test_list_search_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_search_configs(request) @@ -30726,6 +30795,7 @@ def test_list_search_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_search_configs(**mock_args) @@ -30930,6 +31000,7 @@ def test_create_search_hypernym_rest_required_fields( response_value._content = json_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_search_hypernym(request) @@ -30987,6 +31058,7 @@ def test_create_search_hypernym_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_search_hypernym(**mock_args) @@ -31123,6 +31195,7 @@ def test_update_search_hypernym_rest_required_fields( response_value._content = json_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_search_hypernym(request) @@ -31173,6 +31246,7 @@ def test_update_search_hypernym_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_search_hypernym(**mock_args) @@ -31309,6 +31383,7 @@ def test_get_search_hypernym_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_search_hypernym(request) @@ -31356,6 +31431,7 @@ def test_get_search_hypernym_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_search_hypernym(**mock_args) @@ -31489,6 +31565,7 @@ def test_delete_search_hypernym_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_search_hypernym(request) @@ -31534,6 +31611,7 @@ def test_delete_search_hypernym_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_search_hypernym(**mock_args) @@ -31677,6 +31755,7 @@ def test_list_search_hypernyms_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_search_hypernyms(request) @@ -31732,6 +31811,7 @@ def test_list_search_hypernyms_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_search_hypernyms(**mock_args) @@ -31927,6 +32007,7 @@ def test_search_assets_rest_required_fields(request_type=warehouse.SearchAssetsR response_value._content = json_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_assets(request) @@ -32115,6 +32196,7 @@ def test_search_index_endpoint_rest_required_fields( response_value._content = json_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_index_endpoint(request) @@ -32308,6 +32390,7 @@ def test_create_index_endpoint_rest_required_fields( response_value._content = json_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_index_endpoint(request) @@ -32361,6 +32444,7 @@ def test_create_index_endpoint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_index_endpoint(**mock_args) @@ -32498,6 +32582,7 @@ def test_get_index_endpoint_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_index_endpoint(request) @@ -32545,6 +32630,7 @@ def test_get_index_endpoint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_index_endpoint(**mock_args) @@ -32688,6 +32774,7 @@ def test_list_index_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_index_endpoints(request) @@ -32742,6 +32829,7 @@ def test_list_index_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_index_endpoints(**mock_args) @@ -32940,6 +33028,7 @@ def test_update_index_endpoint_rest_required_fields( response_value._content = json_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_index_endpoint(request) @@ -32996,6 +33085,7 @@ def test_update_index_endpoint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_index_endpoint(**mock_args) @@ -33134,6 +33224,7 @@ def test_delete_index_endpoint_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_index_endpoint(request) @@ -33179,6 +33270,7 @@ def test_delete_index_endpoint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_index_endpoint(**mock_args) @@ -33310,6 +33402,7 @@ def test_deploy_index_rest_required_fields(request_type=warehouse.DeployIndexReq response_value._content = json_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_index(request) @@ -33439,6 +33532,7 @@ def test_undeploy_index_rest_required_fields( response_value._content = json_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_index(request) @@ -33564,6 +33658,7 @@ def test_create_collection_rest_required_fields( response_value._content = json_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_collection(request) @@ -33619,6 +33714,7 @@ def test_create_collection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_collection(**mock_args) @@ -33755,6 +33851,7 @@ def test_delete_collection_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_collection(request) @@ -33800,6 +33897,7 @@ def test_delete_collection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_collection(**mock_args) @@ -33931,6 +34029,7 @@ def test_get_collection_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_collection(request) @@ -33978,6 +34077,7 @@ def test_get_collection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_collection(**mock_args) @@ -34109,6 +34209,7 @@ def test_update_collection_rest_required_fields( response_value._content = json_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_collection(request) @@ -34159,6 +34260,7 @@ def test_update_collection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_collection(**mock_args) @@ -34300,6 +34402,7 @@ def test_list_collections_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_collections(request) @@ -34355,6 +34458,7 @@ def test_list_collections_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_collections(**mock_args) @@ -34549,6 +34653,7 @@ def test_add_collection_item_rest_required_fields( response_value._content = json_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_collection_item(request) @@ -34598,6 +34703,7 @@ def test_add_collection_item_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_collection_item(**mock_args) @@ -34730,6 +34836,7 @@ def test_remove_collection_item_rest_required_fields( response_value._content = json_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_collection_item(request) @@ -34779,6 +34886,7 @@ def test_remove_collection_item_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_collection_item(**mock_args) @@ -34922,6 +35030,7 @@ def test_view_collection_items_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.view_collection_items(request) @@ -34977,6 +35086,7 @@ def test_view_collection_items_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.view_collection_items(**mock_args) @@ -38305,6 +38415,7 @@ def test_create_asset_rest_bad_request(request_type=warehouse.CreateAssetRequest response_value.status_code = 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_asset(request) @@ -38412,6 +38523,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_asset(request) # Establish that the response is the type that we expect. @@ -38448,6 +38560,7 @@ def test_create_asset_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.Asset.to_json(warehouse.Asset()) req.return_value.content = return_value @@ -38494,6 +38607,7 @@ def test_update_asset_rest_bad_request(request_type=warehouse.UpdateAssetRequest response_value.status_code = 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_asset(request) @@ -38605,6 +38719,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_asset(request) # Establish that the response is the type that we expect. @@ -38641,6 +38756,7 @@ def test_update_asset_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.Asset.to_json(warehouse.Asset()) req.return_value.content = return_value @@ -38685,6 +38801,7 @@ def test_get_asset_rest_bad_request(request_type=warehouse.GetAssetRequest): response_value.status_code = 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_asset(request) @@ -38722,6 +38839,7 @@ def test_get_asset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_asset(request) # Establish that the response is the type that we expect. @@ -38758,6 +38876,7 @@ def test_get_asset_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.Asset.to_json(warehouse.Asset()) req.return_value.content = return_value @@ -38800,6 +38919,7 @@ def test_list_assets_rest_bad_request(request_type=warehouse.ListAssetsRequest): response_value.status_code = 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_assets(request) @@ -38835,6 +38955,7 @@ def test_list_assets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_assets(request) # Establish that the response is the type that we expect. @@ -38871,6 +38992,7 @@ def test_list_assets_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.ListAssetsResponse.to_json( warehouse.ListAssetsResponse() ) @@ -38917,6 +39039,7 @@ def test_delete_asset_rest_bad_request(request_type=warehouse.DeleteAssetRequest response_value.status_code = 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_asset(request) @@ -38949,6 +39072,7 @@ def test_delete_asset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_asset(request) # Establish that the response is the type that we expect. @@ -38986,6 +39110,7 @@ def test_delete_asset_rest_interceptors(null_interceptor): req.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 @@ -39030,6 +39155,7 @@ def test_upload_asset_rest_bad_request(request_type=warehouse.UploadAssetRequest response_value.status_code = 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_asset(request) @@ -39062,6 +39188,7 @@ def test_upload_asset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_asset(request) # Establish that the response is the type that we expect. @@ -39099,6 +39226,7 @@ def test_upload_asset_rest_interceptors(null_interceptor): req.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 @@ -39145,6 +39273,7 @@ def test_generate_retrieval_url_rest_bad_request( response_value.status_code = 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_retrieval_url(request) @@ -39182,6 +39311,7 @@ def test_generate_retrieval_url_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_retrieval_url(request) # Establish that the response is the type that we expect. @@ -39220,6 +39350,7 @@ def test_generate_retrieval_url_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.GenerateRetrievalUrlResponse.to_json( warehouse.GenerateRetrievalUrlResponse() ) @@ -39266,6 +39397,7 @@ def test_analyze_asset_rest_bad_request(request_type=warehouse.AnalyzeAssetReque response_value.status_code = 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_asset(request) @@ -39298,6 +39430,7 @@ def test_analyze_asset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_asset(request) # Establish that the response is the type that we expect. @@ -39335,6 +39468,7 @@ def test_analyze_asset_rest_interceptors(null_interceptor): req.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 @@ -39379,6 +39513,7 @@ def test_index_asset_rest_bad_request(request_type=warehouse.IndexAssetRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.index_asset(request) @@ -39411,6 +39546,7 @@ def test_index_asset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.index_asset(request) # Establish that the response is the type that we expect. @@ -39448,6 +39584,7 @@ def test_index_asset_rest_interceptors(null_interceptor): req.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 @@ -39494,6 +39631,7 @@ def test_remove_index_asset_rest_bad_request( response_value.status_code = 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_index_asset(request) @@ -39526,6 +39664,7 @@ def test_remove_index_asset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_index_asset(request) # Establish that the response is the type that we expect. @@ -39565,6 +39704,7 @@ def test_remove_index_asset_rest_interceptors(null_interceptor): req.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 @@ -39611,6 +39751,7 @@ def test_view_indexed_assets_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.view_indexed_assets(request) @@ -39648,6 +39789,7 @@ def test_view_indexed_assets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.view_indexed_assets(request) # Establish that the response is the type that we expect. @@ -39686,6 +39828,7 @@ def test_view_indexed_assets_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.ViewIndexedAssetsResponse.to_json( warehouse.ViewIndexedAssetsResponse() ) @@ -39730,6 +39873,7 @@ def test_create_index_rest_bad_request(request_type=warehouse.CreateIndexRequest response_value.status_code = 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_index(request) @@ -39839,6 +39983,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_index(request) # Establish that the response is the type that we expect. @@ -39876,6 +40021,7 @@ def test_create_index_rest_interceptors(null_interceptor): req.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 @@ -39922,6 +40068,7 @@ def test_update_index_rest_bad_request(request_type=warehouse.UpdateIndexRequest response_value.status_code = 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_index(request) @@ -40035,6 +40182,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_index(request) # Establish that the response is the type that we expect. @@ -40072,6 +40220,7 @@ def test_update_index_rest_interceptors(null_interceptor): req.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 @@ -40116,6 +40265,7 @@ def test_get_index_rest_bad_request(request_type=warehouse.GetIndexRequest): response_value.status_code = 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_index(request) @@ -40159,6 +40309,7 @@ def test_get_index_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_index(request) # Establish that the response is the type that we expect. @@ -40200,6 +40351,7 @@ def test_get_index_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.Index.to_json(warehouse.Index()) req.return_value.content = return_value @@ -40242,6 +40394,7 @@ def test_list_indexes_rest_bad_request(request_type=warehouse.ListIndexesRequest response_value.status_code = 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_indexes(request) @@ -40277,6 +40430,7 @@ def test_list_indexes_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_indexes(request) # Establish that the response is the type that we expect. @@ -40313,6 +40467,7 @@ def test_list_indexes_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.ListIndexesResponse.to_json( warehouse.ListIndexesResponse() ) @@ -40359,6 +40514,7 @@ def test_delete_index_rest_bad_request(request_type=warehouse.DeleteIndexRequest response_value.status_code = 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_index(request) @@ -40391,6 +40547,7 @@ def test_delete_index_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_index(request) # Establish that the response is the type that we expect. @@ -40428,6 +40585,7 @@ def test_delete_index_rest_interceptors(null_interceptor): req.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 @@ -40470,6 +40628,7 @@ def test_create_corpus_rest_bad_request(request_type=warehouse.CreateCorpusReque response_value.status_code = 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_corpus(request) @@ -40577,6 +40736,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_corpus(request) # Establish that the response is the type that we expect. @@ -40614,6 +40774,7 @@ def test_create_corpus_rest_interceptors(null_interceptor): req.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 @@ -40656,6 +40817,7 @@ def test_get_corpus_rest_bad_request(request_type=warehouse.GetCorpusRequest): response_value.status_code = 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_corpus(request) @@ -40696,6 +40858,7 @@ def test_get_corpus_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_corpus(request) # Establish that the response is the type that we expect. @@ -40737,6 +40900,7 @@ def test_get_corpus_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.Corpus.to_json(warehouse.Corpus()) req.return_value.content = return_value @@ -40781,6 +40945,7 @@ def test_update_corpus_rest_bad_request(request_type=warehouse.UpdateCorpusReque response_value.status_code = 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_corpus(request) @@ -40900,6 +41065,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_corpus(request) # Establish that the response is the type that we expect. @@ -40941,6 +41107,7 @@ def test_update_corpus_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.Corpus.to_json(warehouse.Corpus()) req.return_value.content = return_value @@ -40983,6 +41150,7 @@ def test_list_corpora_rest_bad_request(request_type=warehouse.ListCorporaRequest response_value.status_code = 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_corpora(request) @@ -41018,6 +41186,7 @@ def test_list_corpora_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_corpora(request) # Establish that the response is the type that we expect. @@ -41054,6 +41223,7 @@ def test_list_corpora_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.ListCorporaResponse.to_json( warehouse.ListCorporaResponse() ) @@ -41098,6 +41268,7 @@ def test_delete_corpus_rest_bad_request(request_type=warehouse.DeleteCorpusReque response_value.status_code = 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_corpus(request) @@ -41128,6 +41299,7 @@ def test_delete_corpus_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_corpus(request) # Establish that the response is the type that we expect. @@ -41160,6 +41332,7 @@ def test_delete_corpus_rest_interceptors(null_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 = warehouse.DeleteCorpusRequest() metadata = [ @@ -41198,6 +41371,7 @@ def test_analyze_corpus_rest_bad_request(request_type=warehouse.AnalyzeCorpusReq response_value.status_code = 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_corpus(request) @@ -41228,6 +41402,7 @@ def test_analyze_corpus_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_corpus(request) # Establish that the response is the type that we expect. @@ -41265,6 +41440,7 @@ def test_analyze_corpus_rest_interceptors(null_interceptor): req.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 @@ -41309,6 +41485,7 @@ def test_create_data_schema_rest_bad_request( response_value.status_code = 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_data_schema(request) @@ -41430,6 +41607,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_data_schema(request) # Establish that the response is the type that we expect. @@ -41469,6 +41647,7 @@ def test_create_data_schema_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.DataSchema.to_json(warehouse.DataSchema()) req.return_value.content = return_value @@ -41517,6 +41696,7 @@ def test_update_data_schema_rest_bad_request( response_value.status_code = 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_data_schema(request) @@ -41642,6 +41822,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_data_schema(request) # Establish that the response is the type that we expect. @@ -41681,6 +41862,7 @@ def test_update_data_schema_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.DataSchema.to_json(warehouse.DataSchema()) req.return_value.content = return_value @@ -41725,6 +41907,7 @@ def test_get_data_schema_rest_bad_request(request_type=warehouse.GetDataSchemaRe response_value.status_code = 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_data_schema(request) @@ -41763,6 +41946,7 @@ def test_get_data_schema_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_data_schema(request) # Establish that the response is the type that we expect. @@ -41800,6 +41984,7 @@ def test_get_data_schema_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.DataSchema.to_json(warehouse.DataSchema()) req.return_value.content = return_value @@ -41846,6 +42031,7 @@ def test_delete_data_schema_rest_bad_request( response_value.status_code = 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_data_schema(request) @@ -41878,6 +42064,7 @@ def test_delete_data_schema_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_data_schema(request) # Establish that the response is the type that we expect. @@ -41912,6 +42099,7 @@ def test_delete_data_schema_rest_interceptors(null_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 = warehouse.DeleteDataSchemaRequest() metadata = [ @@ -41952,6 +42140,7 @@ def test_list_data_schemas_rest_bad_request( response_value.status_code = 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_data_schemas(request) @@ -41987,6 +42176,7 @@ def test_list_data_schemas_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_data_schemas(request) # Establish that the response is the type that we expect. @@ -42025,6 +42215,7 @@ def test_list_data_schemas_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.ListDataSchemasResponse.to_json( warehouse.ListDataSchemasResponse() ) @@ -42073,6 +42264,7 @@ def test_create_annotation_rest_bad_request( response_value.status_code = 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_annotation(request) @@ -42214,6 +42406,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_annotation(request) # Establish that the response is the type that we expect. @@ -42252,6 +42445,7 @@ def test_create_annotation_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.Annotation.to_json(warehouse.Annotation()) req.return_value.content = return_value @@ -42296,6 +42490,7 @@ def test_get_annotation_rest_bad_request(request_type=warehouse.GetAnnotationReq response_value.status_code = 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(request) @@ -42333,6 +42528,7 @@ def test_get_annotation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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(request) # Establish that the response is the type that we expect. @@ -42369,6 +42565,7 @@ def test_get_annotation_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.Annotation.to_json(warehouse.Annotation()) req.return_value.content = return_value @@ -42415,6 +42612,7 @@ def test_list_annotations_rest_bad_request( response_value.status_code = 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_annotations(request) @@ -42452,6 +42650,7 @@ def test_list_annotations_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_annotations(request) # Establish that the response is the type that we expect. @@ -42490,6 +42689,7 @@ def test_list_annotations_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.ListAnnotationsResponse.to_json( warehouse.ListAnnotationsResponse() ) @@ -42540,6 +42740,7 @@ def test_update_annotation_rest_bad_request( response_value.status_code = 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_annotation(request) @@ -42683,6 +42884,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_annotation(request) # Establish that the response is the type that we expect. @@ -42721,6 +42923,7 @@ def test_update_annotation_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.Annotation.to_json(warehouse.Annotation()) req.return_value.content = return_value @@ -42767,6 +42970,7 @@ def test_delete_annotation_rest_bad_request( response_value.status_code = 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_annotation(request) @@ -42799,6 +43003,7 @@ def test_delete_annotation_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_annotation(request) # Establish that the response is the type that we expect. @@ -42833,6 +43038,7 @@ def test_delete_annotation_rest_interceptors(null_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 = warehouse.DeleteAnnotationRequest() metadata = [ @@ -42885,6 +43091,7 @@ def test_clip_asset_rest_bad_request(request_type=warehouse.ClipAssetRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.clip_asset(request) @@ -42920,6 +43127,7 @@ def test_clip_asset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.clip_asset(request) # Establish that the response is the type that we expect. @@ -42955,6 +43163,7 @@ def test_clip_asset_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.ClipAssetResponse.to_json( warehouse.ClipAssetResponse() ) @@ -43003,6 +43212,7 @@ def test_generate_hls_uri_rest_bad_request( response_value.status_code = 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_hls_uri(request) @@ -43040,6 +43250,7 @@ def test_generate_hls_uri_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_hls_uri(request) # Establish that the response is the type that we expect. @@ -43078,6 +43289,7 @@ def test_generate_hls_uri_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.GenerateHlsUriResponse.to_json( warehouse.GenerateHlsUriResponse() ) @@ -43122,6 +43334,7 @@ def test_import_assets_rest_bad_request(request_type=warehouse.ImportAssetsReque response_value.status_code = 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_assets(request) @@ -43152,6 +43365,7 @@ def test_import_assets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_assets(request) # Establish that the response is the type that we expect. @@ -43189,6 +43403,7 @@ def test_import_assets_rest_interceptors(null_interceptor): req.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 @@ -43233,6 +43448,7 @@ def test_create_search_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_search_config(request) @@ -43368,6 +43584,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_search_config(request) # Establish that the response is the type that we expect. @@ -43406,6 +43623,7 @@ def test_create_search_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 = warehouse.SearchConfig.to_json(warehouse.SearchConfig()) req.return_value.content = return_value @@ -43454,6 +43672,7 @@ def test_update_search_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_search_config(request) @@ -43593,6 +43812,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_search_config(request) # Establish that the response is the type that we expect. @@ -43631,6 +43851,7 @@ def test_update_search_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 = warehouse.SearchConfig.to_json(warehouse.SearchConfig()) req.return_value.content = return_value @@ -43677,6 +43898,7 @@ def test_get_search_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_search_config(request) @@ -43714,6 +43936,7 @@ def test_get_search_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_search_config(request) # Establish that the response is the type that we expect. @@ -43752,6 +43975,7 @@ def test_get_search_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 = warehouse.SearchConfig.to_json(warehouse.SearchConfig()) req.return_value.content = return_value @@ -43798,6 +44022,7 @@ def test_delete_search_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_search_config(request) @@ -43830,6 +44055,7 @@ def test_delete_search_config_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_search_config(request) # Establish that the response is the type that we expect. @@ -43864,6 +44090,7 @@ def test_delete_search_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"} request = warehouse.DeleteSearchConfigRequest() metadata = [ @@ -43904,6 +44131,7 @@ def test_list_search_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_search_configs(request) @@ -43939,6 +44167,7 @@ def test_list_search_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_search_configs(request) # Establish that the response is the type that we expect. @@ -43977,6 +44206,7 @@ def test_list_search_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 = warehouse.ListSearchConfigsResponse.to_json( warehouse.ListSearchConfigsResponse() ) @@ -44023,6 +44253,7 @@ def test_create_search_hypernym_rest_bad_request( response_value.status_code = 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_search_hypernym(request) @@ -44132,6 +44363,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_search_hypernym(request) # Establish that the response is the type that we expect. @@ -44172,6 +44404,7 @@ def test_create_search_hypernym_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.SearchHypernym.to_json(warehouse.SearchHypernym()) req.return_value.content = return_value @@ -44220,6 +44453,7 @@ def test_update_search_hypernym_rest_bad_request( response_value.status_code = 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_search_hypernym(request) @@ -44333,6 +44567,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_search_hypernym(request) # Establish that the response is the type that we expect. @@ -44373,6 +44608,7 @@ def test_update_search_hypernym_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.SearchHypernym.to_json(warehouse.SearchHypernym()) req.return_value.content = return_value @@ -44419,6 +44655,7 @@ def test_get_search_hypernym_rest_bad_request( response_value.status_code = 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_search_hypernym(request) @@ -44458,6 +44695,7 @@ def test_get_search_hypernym_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_search_hypernym(request) # Establish that the response is the type that we expect. @@ -44498,6 +44736,7 @@ def test_get_search_hypernym_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.SearchHypernym.to_json(warehouse.SearchHypernym()) req.return_value.content = return_value @@ -44544,6 +44783,7 @@ def test_delete_search_hypernym_rest_bad_request( response_value.status_code = 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_search_hypernym(request) @@ -44576,6 +44816,7 @@ def test_delete_search_hypernym_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_search_hypernym(request) # Establish that the response is the type that we expect. @@ -44610,6 +44851,7 @@ def test_delete_search_hypernym_rest_interceptors(null_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 = warehouse.DeleteSearchHypernymRequest() metadata = [ @@ -44650,6 +44892,7 @@ def test_list_search_hypernyms_rest_bad_request( response_value.status_code = 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_search_hypernyms(request) @@ -44685,6 +44928,7 @@ def test_list_search_hypernyms_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_search_hypernyms(request) # Establish that the response is the type that we expect. @@ -44723,6 +44967,7 @@ def test_list_search_hypernyms_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.ListSearchHypernymsResponse.to_json( warehouse.ListSearchHypernymsResponse() ) @@ -44767,6 +45012,7 @@ def test_search_assets_rest_bad_request(request_type=warehouse.SearchAssetsReque response_value.status_code = 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_assets(request) @@ -44802,6 +45048,7 @@ def test_search_assets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_assets(request) # Establish that the response is the type that we expect. @@ -44838,6 +45085,7 @@ def test_search_assets_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.SearchAssetsResponse.to_json( warehouse.SearchAssetsResponse() ) @@ -44886,6 +45134,7 @@ def test_search_index_endpoint_rest_bad_request( response_value.status_code = 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_index_endpoint(request) @@ -44923,6 +45172,7 @@ def test_search_index_endpoint_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_index_endpoint(request) # Establish that the response is the type that we expect. @@ -44961,6 +45211,7 @@ def test_search_index_endpoint_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.SearchIndexEndpointResponse.to_json( warehouse.SearchIndexEndpointResponse() ) @@ -45007,6 +45258,7 @@ def test_create_index_endpoint_rest_bad_request( response_value.status_code = 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_index_endpoint(request) @@ -45116,6 +45368,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_index_endpoint(request) # Establish that the response is the type that we expect. @@ -45155,6 +45408,7 @@ def test_create_index_endpoint_rest_interceptors(null_interceptor): req.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 @@ -45199,6 +45453,7 @@ def test_get_index_endpoint_rest_bad_request( response_value.status_code = 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_index_endpoint(request) @@ -45239,6 +45494,7 @@ def test_get_index_endpoint_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_index_endpoint(request) # Establish that the response is the type that we expect. @@ -45282,6 +45538,7 @@ def test_get_index_endpoint_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.IndexEndpoint.to_json(warehouse.IndexEndpoint()) req.return_value.content = return_value @@ -45326,6 +45583,7 @@ def test_list_index_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_index_endpoints(request) @@ -45361,6 +45619,7 @@ def test_list_index_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_index_endpoints(request) # Establish that the response is the type that we expect. @@ -45399,6 +45658,7 @@ def test_list_index_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 = warehouse.ListIndexEndpointsResponse.to_json( warehouse.ListIndexEndpointsResponse() ) @@ -45449,6 +45709,7 @@ def test_update_index_endpoint_rest_bad_request( response_value.status_code = 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_index_endpoint(request) @@ -45562,6 +45823,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_index_endpoint(request) # Establish that the response is the type that we expect. @@ -45601,6 +45863,7 @@ def test_update_index_endpoint_rest_interceptors(null_interceptor): req.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 @@ -45645,6 +45908,7 @@ def test_delete_index_endpoint_rest_bad_request( response_value.status_code = 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_index_endpoint(request) @@ -45675,6 +45939,7 @@ def test_delete_index_endpoint_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_index_endpoint(request) # Establish that the response is the type that we expect. @@ -45714,6 +45979,7 @@ def test_delete_index_endpoint_rest_interceptors(null_interceptor): req.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 @@ -45758,6 +46024,7 @@ def test_deploy_index_rest_bad_request(request_type=warehouse.DeployIndexRequest response_value.status_code = 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_index(request) @@ -45790,6 +46057,7 @@ def test_deploy_index_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_index(request) # Establish that the response is the type that we expect. @@ -45827,6 +46095,7 @@ def test_deploy_index_rest_interceptors(null_interceptor): req.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 @@ -45871,6 +46140,7 @@ def test_undeploy_index_rest_bad_request(request_type=warehouse.UndeployIndexReq response_value.status_code = 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_index(request) @@ -45903,6 +46173,7 @@ def test_undeploy_index_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_index(request) # Establish that the response is the type that we expect. @@ -45940,6 +46211,7 @@ def test_undeploy_index_rest_interceptors(null_interceptor): req.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 @@ -45984,6 +46256,7 @@ def test_create_collection_rest_bad_request( response_value.status_code = 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_collection(request) @@ -46086,6 +46359,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_collection(request) # Establish that the response is the type that we expect. @@ -46125,6 +46399,7 @@ def test_create_collection_rest_interceptors(null_interceptor): req.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 @@ -46171,6 +46446,7 @@ def test_delete_collection_rest_bad_request( response_value.status_code = 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_collection(request) @@ -46203,6 +46479,7 @@ def test_delete_collection_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_collection(request) # Establish that the response is the type that we expect. @@ -46242,6 +46519,7 @@ def test_delete_collection_rest_interceptors(null_interceptor): req.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 @@ -46286,6 +46564,7 @@ def test_get_collection_rest_bad_request(request_type=warehouse.GetCollectionReq response_value.status_code = 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_collection(request) @@ -46325,6 +46604,7 @@ def test_get_collection_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_collection(request) # Establish that the response is the type that we expect. @@ -46363,6 +46643,7 @@ def test_get_collection_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.Collection.to_json(warehouse.Collection()) req.return_value.content = return_value @@ -46411,6 +46692,7 @@ def test_update_collection_rest_bad_request( response_value.status_code = 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_collection(request) @@ -46524,6 +46806,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_collection(request) # Establish that the response is the type that we expect. @@ -46564,6 +46847,7 @@ def test_update_collection_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.Collection.to_json(warehouse.Collection()) req.return_value.content = return_value @@ -46608,6 +46892,7 @@ def test_list_collections_rest_bad_request( response_value.status_code = 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_collections(request) @@ -46643,6 +46928,7 @@ def test_list_collections_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_collections(request) # Establish that the response is the type that we expect. @@ -46681,6 +46967,7 @@ def test_list_collections_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.ListCollectionsResponse.to_json( warehouse.ListCollectionsResponse() ) @@ -46731,6 +47018,7 @@ def test_add_collection_item_rest_bad_request( response_value.status_code = 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_collection_item(request) @@ -46768,6 +47056,7 @@ def test_add_collection_item_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_collection_item(request) # Establish that the response is the type that we expect. @@ -46805,6 +47094,7 @@ def test_add_collection_item_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.AddCollectionItemResponse.to_json( warehouse.AddCollectionItemResponse() ) @@ -46855,6 +47145,7 @@ def test_remove_collection_item_rest_bad_request( response_value.status_code = 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_collection_item(request) @@ -46892,6 +47183,7 @@ def test_remove_collection_item_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_collection_item(request) # Establish that the response is the type that we expect. @@ -46929,6 +47221,7 @@ def test_remove_collection_item_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.RemoveCollectionItemResponse.to_json( warehouse.RemoveCollectionItemResponse() ) @@ -46977,6 +47270,7 @@ def test_view_collection_items_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.view_collection_items(request) @@ -47014,6 +47308,7 @@ def test_view_collection_items_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.view_collection_items(request) # Establish that the response is the type that we expect. @@ -47052,6 +47347,7 @@ def test_view_collection_items_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.ViewCollectionItemsResponse.to_json( warehouse.ViewCollectionItemsResponse() ) @@ -47100,6 +47396,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) @@ -47130,6 +47427,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) @@ -47160,6 +47458,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) @@ -47190,6 +47489,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) @@ -47220,6 +47520,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) @@ -47250,6 +47551,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) @@ -47280,6 +47582,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) @@ -47310,6 +47613,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-visionai/tests/unit/gapic/visionai_v1alpha1/test_app_platform.py b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_app_platform.py index 77864a31401b..8eaf46dc641f 100644 --- a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_app_platform.py +++ b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_app_platform.py @@ -10895,6 +10895,7 @@ def test_list_applications_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_applications(request) @@ -10950,6 +10951,7 @@ def test_list_applications_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_applications(**mock_args) @@ -11142,6 +11144,7 @@ def test_get_application_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_application(request) @@ -11189,6 +11192,7 @@ def test_get_application_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_application(**mock_args) @@ -11340,6 +11344,7 @@ def test_create_application_rest_required_fields( response_value._content = json_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_application(request) @@ -11404,6 +11409,7 @@ def test_create_application_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_application(**mock_args) @@ -11544,6 +11550,7 @@ def test_update_application_rest_required_fields( response_value._content = json_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_application(request) @@ -11600,6 +11607,7 @@ def test_update_application_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_application(**mock_args) @@ -11744,6 +11752,7 @@ def test_delete_application_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_application(request) @@ -11797,6 +11806,7 @@ def test_delete_application_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_application(**mock_args) @@ -11934,6 +11944,7 @@ def test_deploy_application_rest_required_fields( response_value._content = json_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_application(request) @@ -11979,6 +11990,7 @@ def test_deploy_application_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_application(**mock_args) @@ -12116,6 +12128,7 @@ def test_undeploy_application_rest_required_fields( response_value._content = json_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_application(request) @@ -12161,6 +12174,7 @@ def test_undeploy_application_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_application(**mock_args) @@ -12299,6 +12313,7 @@ def test_add_application_stream_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.add_application_stream_input(request) @@ -12344,6 +12359,7 @@ def test_add_application_stream_input_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_application_stream_input(**mock_args) @@ -12482,6 +12498,7 @@ def test_remove_application_stream_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.remove_application_stream_input(request) @@ -12529,6 +12546,7 @@ def test_remove_application_stream_input_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_application_stream_input(**mock_args) @@ -12667,6 +12685,7 @@ def test_update_application_stream_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.update_application_stream_input(request) @@ -12714,6 +12733,7 @@ def test_update_application_stream_input_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_application_stream_input(**mock_args) @@ -12854,6 +12874,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) @@ -12911,6 +12932,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) @@ -13103,6 +13125,7 @@ def test_get_instance_rest_required_fields(request_type=platform.GetInstanceRequ response_value._content = json_return_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) @@ -13150,6 +13173,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) @@ -13288,6 +13312,7 @@ def test_create_application_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_application_instances(request) @@ -13341,6 +13366,7 @@ def test_create_application_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_application_instances(**mock_args) @@ -13483,6 +13509,7 @@ def test_delete_application_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_application_instances(request) @@ -13536,6 +13563,7 @@ def test_delete_application_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_application_instances(**mock_args) @@ -13674,6 +13702,7 @@ def test_update_application_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.update_application_instances(request) @@ -13724,6 +13753,7 @@ def test_update_application_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.update_application_instances(**mock_args) @@ -13867,6 +13897,7 @@ def test_list_drafts_rest_required_fields(request_type=platform.ListDraftsReques response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_drafts(request) @@ -13924,6 +13955,7 @@ def test_list_drafts_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_drafts(**mock_args) @@ -14116,6 +14148,7 @@ def test_get_draft_rest_required_fields(request_type=platform.GetDraftRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_draft(request) @@ -14163,6 +14196,7 @@ def test_get_draft_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_draft(**mock_args) @@ -14308,6 +14342,7 @@ def test_create_draft_rest_required_fields(request_type=platform.CreateDraftRequ response_value._content = json_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_draft(request) @@ -14375,6 +14410,7 @@ def test_create_draft_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_draft(**mock_args) @@ -14511,6 +14547,7 @@ def test_update_draft_rest_required_fields(request_type=platform.UpdateDraftRequ response_value._content = json_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_draft(request) @@ -14568,6 +14605,7 @@ def test_update_draft_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_draft(**mock_args) @@ -14701,6 +14739,7 @@ def test_delete_draft_rest_required_fields(request_type=platform.DeleteDraftRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_draft(request) @@ -14746,6 +14785,7 @@ def test_delete_draft_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_draft(**mock_args) @@ -14886,6 +14926,7 @@ def test_list_processors_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_processors(request) @@ -14941,6 +14982,7 @@ def test_list_processors_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_processors(**mock_args) @@ -15139,6 +15181,7 @@ def test_list_prebuilt_processors_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_prebuilt_processors(request) @@ -15184,6 +15227,7 @@ def test_list_prebuilt_processors_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_prebuilt_processors(**mock_args) @@ -15313,6 +15357,7 @@ def test_get_processor_rest_required_fields(request_type=platform.GetProcessorRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_processor(request) @@ -15360,6 +15405,7 @@ def test_get_processor_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_processor(**mock_args) @@ -15509,6 +15555,7 @@ def test_create_processor_rest_required_fields( response_value._content = json_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_processor(request) @@ -15574,6 +15621,7 @@ def test_create_processor_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_processor(**mock_args) @@ -15713,6 +15761,7 @@ def test_update_processor_rest_required_fields( response_value._content = json_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_processor(request) @@ -15769,6 +15818,7 @@ def test_update_processor_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_processor(**mock_args) @@ -15906,6 +15956,7 @@ def test_delete_processor_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_processor(request) @@ -15951,6 +16002,7 @@ def test_delete_processor_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_processor(**mock_args) @@ -17414,6 +17466,7 @@ def test_list_applications_rest_bad_request( response_value.status_code = 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_applications(request) @@ -17450,6 +17503,7 @@ def test_list_applications_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_applications(request) # Establish that the response is the type that we expect. @@ -17491,6 +17545,7 @@ def test_list_applications_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = platform.ListApplicationsResponse.to_json( platform.ListApplicationsResponse() ) @@ -17535,6 +17590,7 @@ def test_get_application_rest_bad_request(request_type=platform.GetApplicationRe response_value.status_code = 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_application(request) @@ -17573,6 +17629,7 @@ def test_get_application_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_application(request) # Establish that the response is the type that we expect. @@ -17614,6 +17671,7 @@ def test_get_application_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = platform.Application.to_json(platform.Application()) req.return_value.content = return_value @@ -17658,6 +17716,7 @@ def test_create_application_rest_bad_request( response_value.status_code = 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_application(request) @@ -17885,6 +17944,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_application(request) # Establish that the response is the type that we expect. @@ -17926,6 +17986,7 @@ def test_create_application_rest_interceptors(null_interceptor): req.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 @@ -17974,6 +18035,7 @@ def test_update_application_rest_bad_request( response_value.status_code = 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_application(request) @@ -18205,6 +18267,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_application(request) # Establish that the response is the type that we expect. @@ -18246,6 +18309,7 @@ def test_update_application_rest_interceptors(null_interceptor): req.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 @@ -18290,6 +18354,7 @@ def test_delete_application_rest_bad_request( response_value.status_code = 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_application(request) @@ -18320,6 +18385,7 @@ def test_delete_application_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_application(request) # Establish that the response is the type that we expect. @@ -18361,6 +18427,7 @@ def test_delete_application_rest_interceptors(null_interceptor): req.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 @@ -18405,6 +18472,7 @@ def test_deploy_application_rest_bad_request( response_value.status_code = 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_application(request) @@ -18435,6 +18503,7 @@ def test_deploy_application_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_application(request) # Establish that the response is the type that we expect. @@ -18476,6 +18545,7 @@ def test_deploy_application_rest_interceptors(null_interceptor): req.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 @@ -18520,6 +18590,7 @@ def test_undeploy_application_rest_bad_request( response_value.status_code = 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_application(request) @@ -18550,6 +18621,7 @@ def test_undeploy_application_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_application(request) # Establish that the response is the type that we expect. @@ -18591,6 +18663,7 @@ def test_undeploy_application_rest_interceptors(null_interceptor): req.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 @@ -18635,6 +18708,7 @@ def test_add_application_stream_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.add_application_stream_input(request) @@ -18665,6 +18739,7 @@ def test_add_application_stream_input_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_application_stream_input(request) # Establish that the response is the type that we expect. @@ -18706,6 +18781,7 @@ def test_add_application_stream_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -18750,6 +18826,7 @@ def test_remove_application_stream_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.remove_application_stream_input(request) @@ -18780,6 +18857,7 @@ def test_remove_application_stream_input_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_application_stream_input(request) # Establish that the response is the type that we expect. @@ -18821,6 +18899,7 @@ def test_remove_application_stream_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -18865,6 +18944,7 @@ def test_update_application_stream_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.update_application_stream_input(request) @@ -18895,6 +18975,7 @@ def test_update_application_stream_input_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_application_stream_input(request) # Establish that the response is the type that we expect. @@ -18936,6 +19017,7 @@ def test_update_application_stream_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -18978,6 +19060,7 @@ def test_list_instances_rest_bad_request(request_type=platform.ListInstancesRequ response_value.status_code = 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) @@ -19014,6 +19097,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. @@ -19053,6 +19137,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 = platform.ListInstancesResponse.to_json( platform.ListInstancesResponse() ) @@ -19099,6 +19184,7 @@ def test_get_instance_rest_bad_request(request_type=platform.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_instance(request) @@ -19139,6 +19225,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. @@ -19180,6 +19267,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 = platform.Instance.to_json(platform.Instance()) req.return_value.content = return_value @@ -19224,6 +19312,7 @@ def test_create_application_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.create_application_instances(request) @@ -19254,6 +19343,7 @@ def test_create_application_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.create_application_instances(request) # Establish that the response is the type that we expect. @@ -19295,6 +19385,7 @@ def test_create_application_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -19339,6 +19430,7 @@ def test_delete_application_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.delete_application_instances(request) @@ -19369,6 +19461,7 @@ def test_delete_application_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.delete_application_instances(request) # Establish that the response is the type that we expect. @@ -19410,6 +19503,7 @@ def test_delete_application_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -19454,6 +19548,7 @@ def test_update_application_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.update_application_instances(request) @@ -19484,6 +19579,7 @@ def test_update_application_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.update_application_instances(request) # Establish that the response is the type that we expect. @@ -19525,6 +19621,7 @@ def test_update_application_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -19567,6 +19664,7 @@ def test_list_drafts_rest_bad_request(request_type=platform.ListDraftsRequest): response_value.status_code = 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_drafts(request) @@ -19603,6 +19701,7 @@ def test_list_drafts_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_drafts(request) # Establish that the response is the type that we expect. @@ -19642,6 +19741,7 @@ def test_list_drafts_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = platform.ListDraftsResponse.to_json( platform.ListDraftsResponse() ) @@ -19688,6 +19788,7 @@ def test_get_draft_rest_bad_request(request_type=platform.GetDraftRequest): response_value.status_code = 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_draft(request) @@ -19727,6 +19828,7 @@ def test_get_draft_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_draft(request) # Establish that the response is the type that we expect. @@ -19767,6 +19869,7 @@ def test_get_draft_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = platform.Draft.to_json(platform.Draft()) req.return_value.content = return_value @@ -19809,6 +19912,7 @@ def test_create_draft_rest_bad_request(request_type=platform.CreateDraftRequest) response_value.status_code = 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_draft(request) @@ -20024,6 +20128,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_draft(request) # Establish that the response is the type that we expect. @@ -20063,6 +20168,7 @@ def test_create_draft_rest_interceptors(null_interceptor): req.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 @@ -20109,6 +20215,7 @@ def test_update_draft_rest_bad_request(request_type=platform.UpdateDraftRequest) response_value.status_code = 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_draft(request) @@ -20328,6 +20435,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_draft(request) # Establish that the response is the type that we expect. @@ -20367,6 +20475,7 @@ def test_update_draft_rest_interceptors(null_interceptor): req.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 @@ -20411,6 +20520,7 @@ def test_delete_draft_rest_bad_request(request_type=platform.DeleteDraftRequest) response_value.status_code = 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_draft(request) @@ -20443,6 +20553,7 @@ def test_delete_draft_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_draft(request) # Establish that the response is the type that we expect. @@ -20482,6 +20593,7 @@ def test_delete_draft_rest_interceptors(null_interceptor): req.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 @@ -20524,6 +20636,7 @@ def test_list_processors_rest_bad_request(request_type=platform.ListProcessorsRe response_value.status_code = 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_processors(request) @@ -20560,6 +20673,7 @@ def test_list_processors_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_processors(request) # Establish that the response is the type that we expect. @@ -20599,6 +20713,7 @@ def test_list_processors_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = platform.ListProcessorsResponse.to_json( platform.ListProcessorsResponse() ) @@ -20645,6 +20760,7 @@ def test_list_prebuilt_processors_rest_bad_request( response_value.status_code = 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_prebuilt_processors(request) @@ -20678,6 +20794,7 @@ def test_list_prebuilt_processors_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_prebuilt_processors(request) # Establish that the response is the type that we expect. @@ -20717,6 +20834,7 @@ def test_list_prebuilt_processors_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = platform.ListPrebuiltProcessorsResponse.to_json( platform.ListPrebuiltProcessorsResponse() ) @@ -20761,6 +20879,7 @@ def test_get_processor_rest_bad_request(request_type=platform.GetProcessorReques response_value.status_code = 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_processor(request) @@ -20806,6 +20925,7 @@ def test_get_processor_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_processor(request) # Establish that the response is the type that we expect. @@ -20854,6 +20974,7 @@ def test_get_processor_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = platform.Processor.to_json(platform.Processor()) req.return_value.content = return_value @@ -20898,6 +21019,7 @@ def test_create_processor_rest_bad_request( response_value.status_code = 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_processor(request) @@ -21054,6 +21176,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_processor(request) # Establish that the response is the type that we expect. @@ -21095,6 +21218,7 @@ def test_create_processor_rest_interceptors(null_interceptor): req.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 @@ -21141,6 +21265,7 @@ def test_update_processor_rest_bad_request( response_value.status_code = 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_processor(request) @@ -21299,6 +21424,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_processor(request) # Establish that the response is the type that we expect. @@ -21340,6 +21466,7 @@ def test_update_processor_rest_interceptors(null_interceptor): req.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 @@ -21384,6 +21511,7 @@ def test_delete_processor_rest_bad_request( response_value.status_code = 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_processor(request) @@ -21414,6 +21542,7 @@ def test_delete_processor_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_processor(request) # Establish that the response is the type that we expect. @@ -21455,6 +21584,7 @@ def test_delete_processor_rest_interceptors(null_interceptor): req.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 @@ -21499,6 +21629,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) @@ -21529,6 +21660,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) @@ -21557,6 +21689,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) @@ -21587,6 +21720,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) @@ -21617,6 +21751,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) @@ -21647,6 +21782,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) @@ -21677,6 +21813,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) @@ -21707,6 +21844,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) @@ -21737,6 +21875,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) @@ -21767,6 +21906,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) @@ -21797,6 +21937,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) @@ -21827,6 +21968,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) @@ -21857,6 +21999,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) @@ -21887,6 +22030,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) @@ -21917,6 +22061,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) @@ -21947,6 +22092,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) @@ -21977,6 +22123,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) @@ -22007,6 +22154,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-visionai/tests/unit/gapic/visionai_v1alpha1/test_live_video_analytics.py b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_live_video_analytics.py index 8a600b491bca..55b59f6ba866 100644 --- a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_live_video_analytics.py +++ b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_live_video_analytics.py @@ -3097,6 +3097,7 @@ def test_list_analyses_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_analyses(request) @@ -3154,6 +3155,7 @@ def test_list_analyses_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_analyses(**mock_args) @@ -3346,6 +3348,7 @@ def test_get_analysis_rest_required_fields(request_type=lva_service.GetAnalysisR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_analysis(request) @@ -3393,6 +3396,7 @@ def test_get_analysis_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_analysis(**mock_args) @@ -3540,6 +3544,7 @@ def test_create_analysis_rest_required_fields( response_value._content = json_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_analysis(request) @@ -3607,6 +3612,7 @@ def test_create_analysis_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_analysis(**mock_args) @@ -3744,6 +3750,7 @@ def test_update_analysis_rest_required_fields( response_value._content = json_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_analysis(request) @@ -3805,6 +3812,7 @@ def test_update_analysis_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_analysis(**mock_args) @@ -3940,6 +3948,7 @@ def test_delete_analysis_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_analysis(request) @@ -3985,6 +3994,7 @@ def test_delete_analysis_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_analysis(**mock_args) @@ -4395,6 +4405,7 @@ def test_list_analyses_rest_bad_request(request_type=lva_service.ListAnalysesReq response_value.status_code = 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_analyses(request) @@ -4431,6 +4442,7 @@ def test_list_analyses_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_analyses(request) # Establish that the response is the type that we expect. @@ -4472,6 +4484,7 @@ def test_list_analyses_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = lva_service.ListAnalysesResponse.to_json( lva_service.ListAnalysesResponse() ) @@ -4518,6 +4531,7 @@ def test_get_analysis_rest_bad_request(request_type=lva_service.GetAnalysisReque response_value.status_code = 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_analysis(request) @@ -4555,6 +4569,7 @@ def test_get_analysis_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_analysis(request) # Establish that the response is the type that we expect. @@ -4593,6 +4608,7 @@ def test_get_analysis_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = lva_resources.Analysis.to_json(lva_resources.Analysis()) req.return_value.content = return_value @@ -4637,6 +4653,7 @@ def test_create_analysis_rest_bad_request( response_value.status_code = 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_analysis(request) @@ -4753,6 +4770,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_analysis(request) # Establish that the response is the type that we expect. @@ -4794,6 +4812,7 @@ def test_create_analysis_rest_interceptors(null_interceptor): req.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 @@ -4842,6 +4861,7 @@ def test_update_analysis_rest_bad_request( response_value.status_code = 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_analysis(request) @@ -4962,6 +4982,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_analysis(request) # Establish that the response is the type that we expect. @@ -5003,6 +5024,7 @@ def test_update_analysis_rest_interceptors(null_interceptor): req.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 @@ -5049,6 +5071,7 @@ def test_delete_analysis_rest_bad_request( response_value.status_code = 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_analysis(request) @@ -5081,6 +5104,7 @@ def test_delete_analysis_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_analysis(request) # Establish that the response is the type that we expect. @@ -5122,6 +5146,7 @@ def test_delete_analysis_rest_interceptors(null_interceptor): req.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 @@ -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_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) @@ -5314,6 +5344,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) @@ -5344,6 +5375,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) @@ -5374,6 +5406,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) @@ -5404,6 +5437,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) @@ -5434,6 +5468,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) @@ -5464,6 +5499,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) @@ -5494,6 +5530,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) @@ -5524,6 +5561,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) @@ -5554,6 +5592,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) @@ -5584,6 +5623,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) @@ -5614,6 +5654,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) @@ -5644,6 +5685,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) @@ -5674,6 +5716,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-visionai/tests/unit/gapic/visionai_v1alpha1/test_streaming_service.py b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_streaming_service.py index ac651edcc7bd..df8edcc41a1f 100644 --- a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_streaming_service.py +++ b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_streaming_service.py @@ -2810,6 +2810,7 @@ def test_acquire_lease_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.acquire_lease(request) @@ -2850,6 +2851,7 @@ def test_acquire_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.acquire_lease(request) # Establish that the response is the type that we expect. @@ -2893,6 +2895,7 @@ def test_acquire_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 = streaming_service.Lease.to_json(streaming_service.Lease()) req.return_value.content = return_value @@ -2937,6 +2940,7 @@ def test_renew_lease_rest_bad_request(request_type=streaming_service.RenewLeaseR response_value.status_code = 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) @@ -2977,6 +2981,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. @@ -3020,6 +3025,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 = streaming_service.Lease.to_json(streaming_service.Lease()) req.return_value.content = return_value @@ -3066,6 +3072,7 @@ def test_release_lease_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.release_lease(request) @@ -3101,6 +3108,7 @@ def test_release_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.release_lease(request) # Establish that the response is the type that we expect. @@ -3140,6 +3148,7 @@ def test_release_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 = streaming_service.ReleaseLeaseResponse.to_json( streaming_service.ReleaseLeaseResponse() ) @@ -3186,6 +3195,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) @@ -3216,6 +3226,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) @@ -3244,6 +3255,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) @@ -3274,6 +3286,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) @@ -3304,6 +3317,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) @@ -3334,6 +3348,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) @@ -3364,6 +3379,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) @@ -3394,6 +3410,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) @@ -3424,6 +3441,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) @@ -3454,6 +3472,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) @@ -3484,6 +3503,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) @@ -3514,6 +3534,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) @@ -3544,6 +3565,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) @@ -3574,6 +3596,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) @@ -3604,6 +3627,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) @@ -3634,6 +3658,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) @@ -3664,6 +3689,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) @@ -3694,6 +3720,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-visionai/tests/unit/gapic/visionai_v1alpha1/test_streams_service.py b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_streams_service.py index cf5b594e35b5..0d9ea2219caf 100644 --- a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_streams_service.py +++ b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_streams_service.py @@ -9400,6 +9400,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) @@ -9455,6 +9456,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) @@ -9649,6 +9651,7 @@ def test_get_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_cluster(request) @@ -9694,6 +9697,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) @@ -9841,6 +9845,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) @@ -9906,6 +9911,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) @@ -10043,6 +10049,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) @@ -10102,6 +10109,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) @@ -10237,6 +10245,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) @@ -10280,6 +10289,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) @@ -10420,6 +10430,7 @@ def test_list_streams_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_streams(request) @@ -10477,6 +10488,7 @@ def test_list_streams_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_streams(**mock_args) @@ -10671,6 +10683,7 @@ def test_get_stream_rest_required_fields(request_type=streams_service.GetStreamR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_stream(request) @@ -10718,6 +10731,7 @@ def test_get_stream_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_stream(**mock_args) @@ -10865,6 +10879,7 @@ def test_create_stream_rest_required_fields( response_value._content = json_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_stream(request) @@ -10932,6 +10947,7 @@ def test_create_stream_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_stream(**mock_args) @@ -11069,6 +11085,7 @@ def test_update_stream_rest_required_fields( response_value._content = json_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_stream(request) @@ -11130,6 +11147,7 @@ def test_update_stream_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_stream(**mock_args) @@ -11265,6 +11283,7 @@ def test_delete_stream_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_stream(request) @@ -11310,6 +11329,7 @@ def test_delete_stream_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_stream(**mock_args) @@ -11449,6 +11469,7 @@ def test_generate_stream_hls_token_rest_required_fields( response_value._content = json_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_stream_hls_token(request) @@ -11496,6 +11517,7 @@ def test_generate_stream_hls_token_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_stream_hls_token(**mock_args) @@ -11636,6 +11658,7 @@ def test_list_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_events(request) @@ -11693,6 +11716,7 @@ def test_list_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_events(**mock_args) @@ -11887,6 +11911,7 @@ def test_get_event_rest_required_fields(request_type=streams_service.GetEventReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_event(request) @@ -11934,6 +11959,7 @@ def test_get_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_event(**mock_args) @@ -12081,6 +12107,7 @@ def test_create_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.create_event(request) @@ -12148,6 +12175,7 @@ def test_create_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.create_event(**mock_args) @@ -12285,6 +12313,7 @@ def test_update_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.update_event(request) @@ -12346,6 +12375,7 @@ def test_update_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.update_event(**mock_args) @@ -12481,6 +12511,7 @@ def test_delete_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.delete_event(request) @@ -12526,6 +12557,7 @@ def test_delete_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.delete_event(**mock_args) @@ -12666,6 +12698,7 @@ def test_list_series_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_series(request) @@ -12723,6 +12756,7 @@ def test_list_series_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_series(**mock_args) @@ -12917,6 +12951,7 @@ def test_get_series_rest_required_fields(request_type=streams_service.GetSeriesR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_series(request) @@ -12964,6 +12999,7 @@ def test_get_series_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_series(**mock_args) @@ -13111,6 +13147,7 @@ def test_create_series_rest_required_fields( response_value._content = json_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_series(request) @@ -13178,6 +13215,7 @@ def test_create_series_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_series(**mock_args) @@ -13315,6 +13353,7 @@ def test_update_series_rest_required_fields( response_value._content = json_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_series(request) @@ -13376,6 +13415,7 @@ def test_update_series_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_series(**mock_args) @@ -13511,6 +13551,7 @@ def test_delete_series_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_series(request) @@ -13556,6 +13597,7 @@ def test_delete_series_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_series(**mock_args) @@ -13707,6 +13749,7 @@ def test_materialize_channel_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.materialize_channel(request) @@ -13774,6 +13817,7 @@ def test_materialize_channel_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.materialize_channel(**mock_args) @@ -15004,6 +15048,7 @@ def test_list_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_clusters(request) @@ -15040,6 +15085,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. @@ -15081,6 +15127,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 = streams_service.ListClustersResponse.to_json( streams_service.ListClustersResponse() ) @@ -15125,6 +15172,7 @@ def test_get_cluster_rest_bad_request(request_type=streams_service.GetClusterReq response_value.status_code = 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) @@ -15163,6 +15211,7 @@ 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. @@ -15206,6 +15255,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 = common.Cluster.to_json(common.Cluster()) req.return_value.content = return_value @@ -15250,6 +15300,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) @@ -15357,6 +15408,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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. @@ -15398,6 +15450,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 @@ -15444,6 +15497,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) @@ -15553,6 +15607,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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. @@ -15594,6 +15649,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 @@ -15638,6 +15694,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) @@ -15668,6 +15725,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. @@ -15709,6 +15767,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 @@ -15751,6 +15810,7 @@ def test_list_streams_rest_bad_request(request_type=streams_service.ListStreamsR response_value.status_code = 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_streams(request) @@ -15787,6 +15847,7 @@ def test_list_streams_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_streams(request) # Establish that the response is the type that we expect. @@ -15828,6 +15889,7 @@ def test_list_streams_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = streams_service.ListStreamsResponse.to_json( streams_service.ListStreamsResponse() ) @@ -15874,6 +15936,7 @@ def test_get_stream_rest_bad_request(request_type=streams_service.GetStreamReque response_value.status_code = 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_stream(request) @@ -15914,6 +15977,7 @@ def test_get_stream_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_stream(request) # Establish that the response is the type that we expect. @@ -15957,6 +16021,7 @@ def test_get_stream_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = streams_resources.Stream.to_json(streams_resources.Stream()) req.return_value.content = return_value @@ -16001,6 +16066,7 @@ def test_create_stream_rest_bad_request( response_value.status_code = 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_stream(request) @@ -16108,6 +16174,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_stream(request) # Establish that the response is the type that we expect. @@ -16149,6 +16216,7 @@ def test_create_stream_rest_interceptors(null_interceptor): req.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 @@ -16197,6 +16265,7 @@ def test_update_stream_rest_bad_request( response_value.status_code = 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_stream(request) @@ -16308,6 +16377,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_stream(request) # Establish that the response is the type that we expect. @@ -16349,6 +16419,7 @@ def test_update_stream_rest_interceptors(null_interceptor): req.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 @@ -16395,6 +16466,7 @@ def test_delete_stream_rest_bad_request( response_value.status_code = 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_stream(request) @@ -16427,6 +16499,7 @@ def test_delete_stream_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_stream(request) # Establish that the response is the type that we expect. @@ -16468,6 +16541,7 @@ def test_delete_stream_rest_interceptors(null_interceptor): req.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 @@ -16514,6 +16588,7 @@ def test_generate_stream_hls_token_rest_bad_request( response_value.status_code = 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_stream_hls_token(request) @@ -16551,6 +16626,7 @@ def test_generate_stream_hls_token_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_stream_hls_token(request) # Establish that the response is the type that we expect. @@ -16591,6 +16667,7 @@ def test_generate_stream_hls_token_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = streams_service.GenerateStreamHlsTokenResponse.to_json( streams_service.GenerateStreamHlsTokenResponse() ) @@ -16635,6 +16712,7 @@ def test_list_events_rest_bad_request(request_type=streams_service.ListEventsReq response_value.status_code = 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_events(request) @@ -16671,6 +16749,7 @@ def test_list_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_events(request) # Establish that the response is the type that we expect. @@ -16712,6 +16791,7 @@ def test_list_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 = streams_service.ListEventsResponse.to_json( streams_service.ListEventsResponse() ) @@ -16758,6 +16838,7 @@ def test_get_event_rest_bad_request(request_type=streams_service.GetEventRequest response_value.status_code = 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_event(request) @@ -16796,6 +16877,7 @@ def test_get_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_event(request) # Establish that the response is the type that we expect. @@ -16837,6 +16919,7 @@ def test_get_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 = streams_resources.Event.to_json(streams_resources.Event()) req.return_value.content = return_value @@ -16879,6 +16962,7 @@ def test_create_event_rest_bad_request(request_type=streams_service.CreateEventR response_value.status_code = 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_event(request) @@ -16985,6 +17069,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_event(request) # Establish that the response is the type that we expect. @@ -17026,6 +17111,7 @@ def test_create_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -17072,6 +17158,7 @@ def test_update_event_rest_bad_request(request_type=streams_service.UpdateEventR response_value.status_code = 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_event(request) @@ -17182,6 +17269,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_event(request) # Establish that the response is the type that we expect. @@ -17223,6 +17311,7 @@ def test_update_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -17267,6 +17356,7 @@ def test_delete_event_rest_bad_request(request_type=streams_service.DeleteEventR response_value.status_code = 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_event(request) @@ -17299,6 +17389,7 @@ def test_delete_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.delete_event(request) # Establish that the response is the type that we expect. @@ -17340,6 +17431,7 @@ def test_delete_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -17382,6 +17474,7 @@ def test_list_series_rest_bad_request(request_type=streams_service.ListSeriesReq response_value.status_code = 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_series(request) @@ -17418,6 +17511,7 @@ def test_list_series_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_series(request) # Establish that the response is the type that we expect. @@ -17459,6 +17553,7 @@ def test_list_series_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = streams_service.ListSeriesResponse.to_json( streams_service.ListSeriesResponse() ) @@ -17505,6 +17600,7 @@ def test_get_series_rest_bad_request(request_type=streams_service.GetSeriesReque response_value.status_code = 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_series(request) @@ -17544,6 +17640,7 @@ def test_get_series_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_series(request) # Establish that the response is the type that we expect. @@ -17586,6 +17683,7 @@ def test_get_series_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = streams_resources.Series.to_json(streams_resources.Series()) req.return_value.content = return_value @@ -17630,6 +17728,7 @@ def test_create_series_rest_bad_request( response_value.status_code = 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_series(request) @@ -17736,6 +17835,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_series(request) # Establish that the response is the type that we expect. @@ -17777,6 +17877,7 @@ def test_create_series_rest_interceptors(null_interceptor): req.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 @@ -17825,6 +17926,7 @@ def test_update_series_rest_bad_request( response_value.status_code = 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_series(request) @@ -17935,6 +18037,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_series(request) # Establish that the response is the type that we expect. @@ -17976,6 +18079,7 @@ def test_update_series_rest_interceptors(null_interceptor): req.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 @@ -18022,6 +18126,7 @@ def test_delete_series_rest_bad_request( response_value.status_code = 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_series(request) @@ -18054,6 +18159,7 @@ def test_delete_series_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_series(request) # Establish that the response is the type that we expect. @@ -18095,6 +18201,7 @@ def test_delete_series_rest_interceptors(null_interceptor): req.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 @@ -18139,6 +18246,7 @@ def test_materialize_channel_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.materialize_channel(request) @@ -18245,6 +18353,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.materialize_channel(request) # Establish that the response is the type that we expect. @@ -18286,6 +18395,7 @@ def test_materialize_channel_rest_interceptors(null_interceptor): req.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 @@ -18330,6 +18440,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) @@ -18360,6 +18471,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) @@ -18388,6 +18500,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) @@ -18418,6 +18531,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) @@ -18448,6 +18562,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) @@ -18478,6 +18593,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) @@ -18508,6 +18624,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) @@ -18538,6 +18655,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) @@ -18568,6 +18686,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) @@ -18598,6 +18717,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) @@ -18628,6 +18748,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) @@ -18658,6 +18779,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) @@ -18688,6 +18810,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) @@ -18718,6 +18841,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) @@ -18748,6 +18872,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) @@ -18778,6 +18903,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) @@ -18808,6 +18934,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) @@ -18838,6 +18965,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-visionai/tests/unit/gapic/visionai_v1alpha1/test_warehouse.py b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_warehouse.py index 6423d63b2d59..5f200dcb68dd 100644 --- a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_warehouse.py +++ b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_warehouse.py @@ -11562,6 +11562,7 @@ def test_create_asset_rest_required_fields(request_type=warehouse.CreateAssetReq response_value._content = json_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_asset(request) @@ -11619,6 +11620,7 @@ def test_create_asset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_asset(**mock_args) @@ -11748,6 +11750,7 @@ def test_update_asset_rest_required_fields(request_type=warehouse.UpdateAssetReq response_value._content = json_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_asset(request) @@ -11798,6 +11801,7 @@ def test_update_asset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_asset(**mock_args) @@ -11928,6 +11932,7 @@ def test_get_asset_rest_required_fields(request_type=warehouse.GetAssetRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_asset(request) @@ -11975,6 +11980,7 @@ def test_get_asset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_asset(**mock_args) @@ -12111,6 +12117,7 @@ def test_list_assets_rest_required_fields(request_type=warehouse.ListAssetsReque response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_assets(request) @@ -12166,6 +12173,7 @@ def test_list_assets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_assets(**mock_args) @@ -12359,6 +12367,7 @@ def test_delete_asset_rest_required_fields(request_type=warehouse.DeleteAssetReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_asset(request) @@ -12404,6 +12413,7 @@ def test_delete_asset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_asset(**mock_args) @@ -12535,6 +12545,7 @@ def test_create_corpus_rest_required_fields(request_type=warehouse.CreateCorpusR response_value._content = json_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_corpus(request) @@ -12587,6 +12598,7 @@ def test_create_corpus_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_corpus(**mock_args) @@ -12717,6 +12729,7 @@ def test_get_corpus_rest_required_fields(request_type=warehouse.GetCorpusRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_corpus(request) @@ -12762,6 +12775,7 @@ def test_get_corpus_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_corpus(**mock_args) @@ -12889,6 +12903,7 @@ def test_update_corpus_rest_required_fields(request_type=warehouse.UpdateCorpusR response_value._content = json_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_corpus(request) @@ -12937,6 +12952,7 @@ def test_update_corpus_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_corpus(**mock_args) @@ -13074,6 +13090,7 @@ def test_list_corpora_rest_required_fields(request_type=warehouse.ListCorporaReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_corpora(request) @@ -13127,6 +13144,7 @@ def test_list_corpora_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_corpora(**mock_args) @@ -13314,6 +13332,7 @@ def test_delete_corpus_rest_required_fields(request_type=warehouse.DeleteCorpusR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_corpus(request) @@ -13357,6 +13376,7 @@ def test_delete_corpus_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_corpus(**mock_args) @@ -13493,6 +13513,7 @@ def test_create_data_schema_rest_required_fields( response_value._content = json_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_data_schema(request) @@ -13549,6 +13570,7 @@ def test_create_data_schema_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_data_schema(**mock_args) @@ -13683,6 +13705,7 @@ def test_update_data_schema_rest_required_fields( response_value._content = json_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_data_schema(request) @@ -13733,6 +13756,7 @@ def test_update_data_schema_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_data_schema(**mock_args) @@ -13865,6 +13889,7 @@ def test_get_data_schema_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_data_schema(request) @@ -13912,6 +13937,7 @@ def test_get_data_schema_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_data_schema(**mock_args) @@ -14044,6 +14070,7 @@ def test_delete_data_schema_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_data_schema(request) @@ -14089,6 +14116,7 @@ def test_delete_data_schema_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_data_schema(**mock_args) @@ -14229,6 +14257,7 @@ def test_list_data_schemas_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_data_schemas(request) @@ -14284,6 +14313,7 @@ def test_list_data_schemas_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_data_schemas(**mock_args) @@ -14483,6 +14513,7 @@ def test_create_annotation_rest_required_fields( response_value._content = json_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_annotation(request) @@ -14540,6 +14571,7 @@ def test_create_annotation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_annotation(**mock_args) @@ -14673,6 +14705,7 @@ def test_get_annotation_rest_required_fields( response_value._content = json_return_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(request) @@ -14720,6 +14753,7 @@ def test_get_annotation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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(**mock_args) @@ -14817,6 +14851,7 @@ def test_list_annotations_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_annotations(**mock_args) @@ -15011,6 +15046,7 @@ def test_update_annotation_rest_required_fields( response_value._content = json_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_annotation(request) @@ -15061,6 +15097,7 @@ def test_update_annotation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_annotation(**mock_args) @@ -15192,6 +15229,7 @@ def test_delete_annotation_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_annotation(request) @@ -15237,6 +15275,7 @@ def test_delete_annotation_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_annotation(**mock_args) @@ -15378,6 +15417,7 @@ def test_clip_asset_rest_required_fields(request_type=warehouse.ClipAssetRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.clip_asset(request) @@ -15508,6 +15548,7 @@ def test_generate_hls_uri_rest_required_fields( response_value._content = json_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_hls_uri(request) @@ -15649,6 +15690,7 @@ def test_create_search_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_search_config(request) @@ -15713,6 +15755,7 @@ def test_create_search_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_search_config(**mock_args) @@ -15848,6 +15891,7 @@ def test_update_search_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_search_config(request) @@ -15898,6 +15942,7 @@ def test_update_search_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_search_config(**mock_args) @@ -16032,6 +16077,7 @@ def test_get_search_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_search_config(request) @@ -16079,6 +16125,7 @@ def test_get_search_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_search_config(**mock_args) @@ -16211,6 +16258,7 @@ def test_delete_search_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_search_config(request) @@ -16256,6 +16304,7 @@ def test_delete_search_config_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_search_config(**mock_args) @@ -16398,6 +16447,7 @@ def test_list_search_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_search_configs(request) @@ -16453,6 +16503,7 @@ def test_list_search_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_search_configs(**mock_args) @@ -16648,6 +16699,7 @@ def test_search_assets_rest_required_fields(request_type=warehouse.SearchAssetsR response_value._content = json_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_assets(request) @@ -18264,6 +18316,7 @@ def test_create_asset_rest_bad_request(request_type=warehouse.CreateAssetRequest response_value.status_code = 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_asset(request) @@ -18370,6 +18423,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_asset(request) # Establish that the response is the type that we expect. @@ -18406,6 +18460,7 @@ def test_create_asset_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.Asset.to_json(warehouse.Asset()) req.return_value.content = return_value @@ -18452,6 +18507,7 @@ def test_update_asset_rest_bad_request(request_type=warehouse.UpdateAssetRequest response_value.status_code = 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_asset(request) @@ -18562,6 +18618,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_asset(request) # Establish that the response is the type that we expect. @@ -18598,6 +18655,7 @@ def test_update_asset_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.Asset.to_json(warehouse.Asset()) req.return_value.content = return_value @@ -18642,6 +18700,7 @@ def test_get_asset_rest_bad_request(request_type=warehouse.GetAssetRequest): response_value.status_code = 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_asset(request) @@ -18679,6 +18738,7 @@ def test_get_asset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_asset(request) # Establish that the response is the type that we expect. @@ -18715,6 +18775,7 @@ def test_get_asset_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.Asset.to_json(warehouse.Asset()) req.return_value.content = return_value @@ -18757,6 +18818,7 @@ def test_list_assets_rest_bad_request(request_type=warehouse.ListAssetsRequest): response_value.status_code = 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_assets(request) @@ -18792,6 +18854,7 @@ def test_list_assets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_assets(request) # Establish that the response is the type that we expect. @@ -18828,6 +18891,7 @@ def test_list_assets_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.ListAssetsResponse.to_json( warehouse.ListAssetsResponse() ) @@ -18874,6 +18938,7 @@ def test_delete_asset_rest_bad_request(request_type=warehouse.DeleteAssetRequest response_value.status_code = 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_asset(request) @@ -18906,6 +18971,7 @@ def test_delete_asset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_asset(request) # Establish that the response is the type that we expect. @@ -18943,6 +19009,7 @@ def test_delete_asset_rest_interceptors(null_interceptor): req.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 @@ -18985,6 +19052,7 @@ def test_create_corpus_rest_bad_request(request_type=warehouse.CreateCorpusReque response_value.status_code = 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_corpus(request) @@ -19088,6 +19156,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_corpus(request) # Establish that the response is the type that we expect. @@ -19125,6 +19194,7 @@ def test_create_corpus_rest_interceptors(null_interceptor): req.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 @@ -19167,6 +19237,7 @@ def test_get_corpus_rest_bad_request(request_type=warehouse.GetCorpusRequest): response_value.status_code = 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_corpus(request) @@ -19204,6 +19275,7 @@ def test_get_corpus_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_corpus(request) # Establish that the response is the type that we expect. @@ -19242,6 +19314,7 @@ def test_get_corpus_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.Corpus.to_json(warehouse.Corpus()) req.return_value.content = return_value @@ -19286,6 +19359,7 @@ def test_update_corpus_rest_bad_request(request_type=warehouse.UpdateCorpusReque response_value.status_code = 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_corpus(request) @@ -19398,6 +19472,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_corpus(request) # Establish that the response is the type that we expect. @@ -19436,6 +19511,7 @@ def test_update_corpus_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.Corpus.to_json(warehouse.Corpus()) req.return_value.content = return_value @@ -19478,6 +19554,7 @@ def test_list_corpora_rest_bad_request(request_type=warehouse.ListCorporaRequest response_value.status_code = 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_corpora(request) @@ -19513,6 +19590,7 @@ def test_list_corpora_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_corpora(request) # Establish that the response is the type that we expect. @@ -19549,6 +19627,7 @@ def test_list_corpora_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.ListCorporaResponse.to_json( warehouse.ListCorporaResponse() ) @@ -19593,6 +19672,7 @@ def test_delete_corpus_rest_bad_request(request_type=warehouse.DeleteCorpusReque response_value.status_code = 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_corpus(request) @@ -19623,6 +19703,7 @@ def test_delete_corpus_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_corpus(request) # Establish that the response is the type that we expect. @@ -19655,6 +19736,7 @@ def test_delete_corpus_rest_interceptors(null_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 = warehouse.DeleteCorpusRequest() metadata = [ @@ -19695,6 +19777,7 @@ def test_create_data_schema_rest_bad_request( response_value.status_code = 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_data_schema(request) @@ -19808,6 +19891,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_data_schema(request) # Establish that the response is the type that we expect. @@ -19847,6 +19931,7 @@ def test_create_data_schema_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.DataSchema.to_json(warehouse.DataSchema()) req.return_value.content = return_value @@ -19895,6 +19980,7 @@ def test_update_data_schema_rest_bad_request( response_value.status_code = 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_data_schema(request) @@ -20012,6 +20098,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_data_schema(request) # Establish that the response is the type that we expect. @@ -20051,6 +20138,7 @@ def test_update_data_schema_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.DataSchema.to_json(warehouse.DataSchema()) req.return_value.content = return_value @@ -20095,6 +20183,7 @@ def test_get_data_schema_rest_bad_request(request_type=warehouse.GetDataSchemaRe response_value.status_code = 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_data_schema(request) @@ -20133,6 +20222,7 @@ def test_get_data_schema_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_data_schema(request) # Establish that the response is the type that we expect. @@ -20170,6 +20260,7 @@ def test_get_data_schema_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.DataSchema.to_json(warehouse.DataSchema()) req.return_value.content = return_value @@ -20216,6 +20307,7 @@ def test_delete_data_schema_rest_bad_request( response_value.status_code = 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_data_schema(request) @@ -20248,6 +20340,7 @@ def test_delete_data_schema_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_data_schema(request) # Establish that the response is the type that we expect. @@ -20282,6 +20375,7 @@ def test_delete_data_schema_rest_interceptors(null_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 = warehouse.DeleteDataSchemaRequest() metadata = [ @@ -20322,6 +20416,7 @@ def test_list_data_schemas_rest_bad_request( response_value.status_code = 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_data_schemas(request) @@ -20357,6 +20452,7 @@ def test_list_data_schemas_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_data_schemas(request) # Establish that the response is the type that we expect. @@ -20395,6 +20491,7 @@ def test_list_data_schemas_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.ListDataSchemasResponse.to_json( warehouse.ListDataSchemasResponse() ) @@ -20443,6 +20540,7 @@ def test_create_annotation_rest_bad_request( response_value.status_code = 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_annotation(request) @@ -20578,6 +20676,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_annotation(request) # Establish that the response is the type that we expect. @@ -20616,6 +20715,7 @@ def test_create_annotation_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.Annotation.to_json(warehouse.Annotation()) req.return_value.content = return_value @@ -20660,6 +20760,7 @@ def test_get_annotation_rest_bad_request(request_type=warehouse.GetAnnotationReq response_value.status_code = 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(request) @@ -20697,6 +20798,7 @@ def test_get_annotation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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(request) # Establish that the response is the type that we expect. @@ -20733,6 +20835,7 @@ def test_get_annotation_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.Annotation.to_json(warehouse.Annotation()) req.return_value.content = return_value @@ -20779,6 +20882,7 @@ def test_list_annotations_rest_bad_request( response_value.status_code = 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_annotations(request) @@ -20816,6 +20920,7 @@ def test_list_annotations_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_annotations(request) # Establish that the response is the type that we expect. @@ -20854,6 +20959,7 @@ def test_list_annotations_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.ListAnnotationsResponse.to_json( warehouse.ListAnnotationsResponse() ) @@ -20904,6 +21010,7 @@ def test_update_annotation_rest_bad_request( response_value.status_code = 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_annotation(request) @@ -21041,6 +21148,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_annotation(request) # Establish that the response is the type that we expect. @@ -21079,6 +21187,7 @@ def test_update_annotation_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.Annotation.to_json(warehouse.Annotation()) req.return_value.content = return_value @@ -21125,6 +21234,7 @@ def test_delete_annotation_rest_bad_request( response_value.status_code = 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_annotation(request) @@ -21157,6 +21267,7 @@ def test_delete_annotation_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_annotation(request) # Establish that the response is the type that we expect. @@ -21191,6 +21302,7 @@ def test_delete_annotation_rest_interceptors(null_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 = warehouse.DeleteAnnotationRequest() metadata = [ @@ -21243,6 +21355,7 @@ def test_clip_asset_rest_bad_request(request_type=warehouse.ClipAssetRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.clip_asset(request) @@ -21278,6 +21391,7 @@ def test_clip_asset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.clip_asset(request) # Establish that the response is the type that we expect. @@ -21313,6 +21427,7 @@ def test_clip_asset_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.ClipAssetResponse.to_json( warehouse.ClipAssetResponse() ) @@ -21361,6 +21476,7 @@ def test_generate_hls_uri_rest_bad_request( response_value.status_code = 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_hls_uri(request) @@ -21398,6 +21514,7 @@ def test_generate_hls_uri_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_hls_uri(request) # Establish that the response is the type that we expect. @@ -21436,6 +21553,7 @@ def test_generate_hls_uri_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.GenerateHlsUriResponse.to_json( warehouse.GenerateHlsUriResponse() ) @@ -21482,6 +21600,7 @@ def test_create_search_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_search_config(request) @@ -21617,6 +21736,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_search_config(request) # Establish that the response is the type that we expect. @@ -21655,6 +21775,7 @@ def test_create_search_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 = warehouse.SearchConfig.to_json(warehouse.SearchConfig()) req.return_value.content = return_value @@ -21703,6 +21824,7 @@ def test_update_search_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_search_config(request) @@ -21842,6 +21964,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_search_config(request) # Establish that the response is the type that we expect. @@ -21880,6 +22003,7 @@ def test_update_search_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 = warehouse.SearchConfig.to_json(warehouse.SearchConfig()) req.return_value.content = return_value @@ -21926,6 +22050,7 @@ def test_get_search_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_search_config(request) @@ -21963,6 +22088,7 @@ def test_get_search_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_search_config(request) # Establish that the response is the type that we expect. @@ -22001,6 +22127,7 @@ def test_get_search_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 = warehouse.SearchConfig.to_json(warehouse.SearchConfig()) req.return_value.content = return_value @@ -22047,6 +22174,7 @@ def test_delete_search_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_search_config(request) @@ -22079,6 +22207,7 @@ def test_delete_search_config_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_search_config(request) # Establish that the response is the type that we expect. @@ -22113,6 +22242,7 @@ def test_delete_search_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"} request = warehouse.DeleteSearchConfigRequest() metadata = [ @@ -22153,6 +22283,7 @@ def test_list_search_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_search_configs(request) @@ -22188,6 +22319,7 @@ def test_list_search_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_search_configs(request) # Establish that the response is the type that we expect. @@ -22226,6 +22358,7 @@ def test_list_search_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 = warehouse.ListSearchConfigsResponse.to_json( warehouse.ListSearchConfigsResponse() ) @@ -22270,6 +22403,7 @@ def test_search_assets_rest_bad_request(request_type=warehouse.SearchAssetsReque response_value.status_code = 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_assets(request) @@ -22305,6 +22439,7 @@ def test_search_assets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_assets(request) # Establish that the response is the type that we expect. @@ -22341,6 +22476,7 @@ def test_search_assets_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = warehouse.SearchAssetsResponse.to_json( warehouse.SearchAssetsResponse() ) @@ -22387,6 +22523,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) @@ -22417,6 +22554,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) @@ -22445,6 +22583,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) @@ -22475,6 +22614,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) @@ -22505,6 +22645,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) @@ -22535,6 +22676,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) @@ -22565,6 +22707,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) @@ -22595,6 +22738,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) @@ -22625,6 +22769,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) @@ -22655,6 +22800,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) @@ -22685,6 +22831,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) @@ -22715,6 +22862,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) @@ -22745,6 +22893,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) @@ -22775,6 +22924,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) @@ -22805,6 +22955,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) @@ -22835,6 +22986,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) @@ -22865,6 +23017,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) @@ -22895,6 +23048,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-vm-migration/google/cloud/vmmigration/gapic_version.py b/packages/google-cloud-vm-migration/google/cloud/vmmigration/gapic_version.py index 402b34e179e9..558c8aab67c5 100644 --- a/packages/google-cloud-vm-migration/google/cloud/vmmigration/gapic_version.py +++ b/packages/google-cloud-vm-migration/google/cloud/vmmigration/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.9.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/gapic_version.py b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/gapic_version.py index 402b34e179e9..558c8aab67c5 100644 --- a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/gapic_version.py +++ b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.9.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/async_client.py b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/async_client.py index 39254fae861a..14a30782cf03 100644 --- a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/async_client.py +++ b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/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, VmMigrationTransport from .transports.grpc_asyncio import VmMigrationGrpcAsyncIOTransport +try: + from google.api_core import client_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 VmMigrationAsyncClient: """VM Migration Service""" @@ -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.vmmigration_v1.VmMigrationAsyncClient`.", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "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.vmmigration.v1.VmMigration", + "credentialsType": None, + }, + ) + async def list_sources( self, request: Optional[Union[vmmigration.ListSourcesRequest, dict]] = None, @@ -295,7 +327,7 @@ async def list_sources( 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.ListSourcesAsyncPager: r"""Lists Sources in a given project and location. @@ -341,8 +373,10 @@ async def sample_list_sources(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListSourcesAsyncPager: @@ -417,7 +451,7 @@ async def get_source( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.Source: r"""Gets details of a single Source. @@ -459,8 +493,10 @@ async def sample_get_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.cloud.vmmigration_v1.types.Source: @@ -525,7 +561,7 @@ async def create_source( source_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 Source in a given project and location. @@ -582,8 +618,10 @@ async def sample_create_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: @@ -659,7 +697,7 @@ async def update_source( 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 Source. @@ -715,8 +753,10 @@ async def sample_update_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: @@ -791,7 +831,7 @@ async def delete_source( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Source. @@ -837,8 +877,10 @@ async def sample_delete_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: @@ -917,7 +959,7 @@ async def fetch_inventory( source: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.FetchInventoryResponse: r"""List remote source's inventory of VMs. The remote source is the onprem vCenter (remote in the @@ -965,8 +1007,10 @@ async def sample_fetch_inventory(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmmigration_v1.types.FetchInventoryResponse: @@ -1029,7 +1073,7 @@ async def list_utilization_reports( 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.ListUtilizationReportsAsyncPager: r"""Lists Utilization Reports of the given Source. @@ -1075,8 +1119,10 @@ async def sample_list_utilization_reports(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListUtilizationReportsAsyncPager: @@ -1151,7 +1197,7 @@ async def get_utilization_report( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.UtilizationReport: r"""Gets a single Utilization Report. @@ -1195,8 +1241,10 @@ async def sample_get_utilization_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.vmmigration_v1.types.UtilizationReport: @@ -1262,7 +1310,7 @@ async def create_utilization_report( utilization_report_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 UtilizationReport. @@ -1328,8 +1376,10 @@ async def sample_create_utilization_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.api_core.operation_async.AsyncOperation: @@ -1406,7 +1456,7 @@ async def delete_utilization_report( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Utilization Report. @@ -1454,8 +1504,10 @@ async def sample_delete_utilization_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.api_core.operation_async.AsyncOperation: @@ -1536,7 +1588,7 @@ async def list_datacenter_connectors( 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.ListDatacenterConnectorsAsyncPager: r"""Lists DatacenterConnectors in a given Source. @@ -1582,8 +1634,10 @@ async def sample_list_datacenter_connectors(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListDatacenterConnectorsAsyncPager: @@ -1660,7 +1714,7 @@ async def get_datacenter_connector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.DatacenterConnector: r"""Gets details of a single DatacenterConnector. @@ -1704,8 +1758,10 @@ async def sample_get_datacenter_connector(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmmigration_v1.types.DatacenterConnector: @@ -1775,7 +1831,7 @@ async def create_datacenter_connector( datacenter_connector_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 DatacenterConnector in a given Source. @@ -1838,8 +1894,10 @@ async def sample_create_datacenter_connector(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1921,7 +1979,7 @@ async def delete_datacenter_connector( name: Optional[str] = None, retry: OptionalRetry = gapic_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 DatacenterConnector. @@ -1969,8 +2027,10 @@ async def sample_delete_datacenter_connector(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2048,7 +2108,7 @@ async def upgrade_appliance( *, retry: OptionalRetry = gapic_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"""Upgrades the appliance relate to this DatacenterConnector to the in-place updateable version. @@ -2090,8 +2150,10 @@ async def sample_upgrade_appliance(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2153,7 +2215,7 @@ async def create_migrating_vm( migrating_vm_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 MigratingVm in a given Source. @@ -2210,8 +2272,10 @@ async def sample_create_migrating_vm(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2286,7 +2350,7 @@ async def list_migrating_vms( 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.ListMigratingVmsAsyncPager: r"""Lists MigratingVms in a given Source. @@ -2332,8 +2396,10 @@ async def sample_list_migrating_vms(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListMigratingVmsAsyncPager: @@ -2408,7 +2474,7 @@ async def get_migrating_vm( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.MigratingVm: r"""Gets details of a single MigratingVm. @@ -2452,8 +2518,10 @@ async def sample_get_migrating_vm(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmmigration_v1.types.MigratingVm: @@ -2516,7 +2584,7 @@ async def update_migrating_vm( 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 MigratingVm. @@ -2572,8 +2640,10 @@ async def sample_update_migrating_vm(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2648,7 +2718,7 @@ async def delete_migrating_vm( name: Optional[str] = None, retry: OptionalRetry = gapic_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 MigratingVm. @@ -2696,8 +2766,10 @@ async def sample_delete_migrating_vm(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2776,7 +2848,7 @@ async def start_migration( migrating_vm: Optional[str] = None, retry: OptionalRetry = gapic_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"""Starts migration for a VM. Starts the process of uploading data and creating snapshots, in replication @@ -2826,8 +2898,10 @@ async def sample_start_migration(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2900,7 +2974,7 @@ async def resume_migration( *, retry: OptionalRetry = gapic_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"""Resumes a migration for a VM. When called on a paused migration, will start the process of uploading data and @@ -2946,8 +3020,10 @@ async def sample_resume_migration(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3006,7 +3082,7 @@ async def pause_migration( *, retry: OptionalRetry = gapic_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"""Pauses a migration for a VM. If cycle tasks are running they will be cancelled, preserving source task @@ -3050,8 +3126,10 @@ async def sample_pause_migration(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3111,7 +3189,7 @@ async def finalize_migration( migrating_vm: Optional[str] = None, retry: OptionalRetry = gapic_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"""Marks a migration as completed, deleting migration resources that are no longer being used. Only applicable @@ -3161,8 +3239,10 @@ async def sample_finalize_migration(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3238,7 +3318,7 @@ async def create_clone_job( clone_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]]] = (), ) -> operation_async.AsyncOperation: r"""Initiates a Clone of a specific migrating VM. @@ -3295,8 +3375,10 @@ async def sample_create_clone_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: @@ -3383,7 +3465,7 @@ async def cancel_clone_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"""Initiates the cancellation of a running clone job. @@ -3429,8 +3511,10 @@ async def sample_cancel_clone_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: @@ -3502,7 +3586,7 @@ async def list_clone_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.ListCloneJobsAsyncPager: r"""Lists CloneJobs of a given migrating VM. @@ -3548,8 +3632,10 @@ async def sample_list_clone_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.vmmigration_v1.services.vm_migration.pagers.ListCloneJobsAsyncPager: @@ -3624,7 +3710,7 @@ async def get_clone_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]]] = (), ) -> vmmigration.CloneJob: r"""Gets details of a single CloneJob. @@ -3666,8 +3752,10 @@ async def sample_get_clone_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.vmmigration_v1.types.CloneJob: @@ -3742,7 +3830,7 @@ async def create_cutover_job( cutover_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]]] = (), ) -> operation_async.AsyncOperation: r"""Initiates a Cutover of a specific migrating VM. The returned LRO is completed when the cutover job @@ -3801,8 +3889,10 @@ async def sample_create_cutover_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: @@ -3879,7 +3969,7 @@ async def cancel_cutover_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"""Initiates the cancellation of a running cutover job. @@ -3925,8 +4015,10 @@ async def sample_cancel_cutover_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: @@ -3998,7 +4090,7 @@ async def list_cutover_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.ListCutoverJobsAsyncPager: r"""Lists CutoverJobs of a given migrating VM. @@ -4044,8 +4136,10 @@ async def sample_list_cutover_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.vmmigration_v1.services.vm_migration.pagers.ListCutoverJobsAsyncPager: @@ -4120,7 +4214,7 @@ async def get_cutover_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]]] = (), ) -> vmmigration.CutoverJob: r"""Gets details of a single CutoverJob. @@ -4162,8 +4256,10 @@ async def sample_get_cutover_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.vmmigration_v1.types.CutoverJob: @@ -4228,7 +4324,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 project and location. @@ -4274,8 +4370,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.vmmigration_v1.services.vm_migration.pagers.ListGroupsAsyncPager: @@ -4350,7 +4448,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]]] = (), ) -> vmmigration.Group: r"""Gets details of a single Group. @@ -4392,8 +4490,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.vmmigration_v1.types.Group: @@ -4457,7 +4557,7 @@ async def create_group( group_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 Group in a given project and location. @@ -4514,8 +4614,10 @@ async def sample_create_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.api_core.operation_async.AsyncOperation: @@ -4591,7 +4693,7 @@ async def update_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]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Group. @@ -4647,8 +4749,10 @@ async def sample_update_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.api_core.operation_async.AsyncOperation: @@ -4723,7 +4827,7 @@ async def delete_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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Group. @@ -4769,8 +4873,10 @@ async def sample_delete_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.api_core.operation_async.AsyncOperation: @@ -4849,7 +4955,7 @@ async def add_group_migration( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Adds a MigratingVm to a Group. @@ -4897,8 +5003,10 @@ async def sample_add_group_migration(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -4970,7 +5078,7 @@ async def remove_group_migration( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Removes a MigratingVm from a Group. @@ -5016,8 +5124,10 @@ async def sample_remove_group_migration(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -5089,7 +5199,7 @@ async def list_target_projects( 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.ListTargetProjectsAsyncPager: r"""Lists TargetProjects in a given project. @@ -5138,8 +5248,10 @@ async def sample_list_target_projects(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListTargetProjectsAsyncPager: @@ -5214,7 +5326,7 @@ async def get_target_project( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.TargetProject: r"""Gets details of a single TargetProject. @@ -5259,8 +5371,10 @@ async def sample_get_target_project(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmmigration_v1.types.TargetProject: @@ -5324,7 +5438,7 @@ async def create_target_project( target_project_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 TargetProject in a given project. @@ -5384,8 +5498,10 @@ async def sample_create_target_project(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -5461,7 +5577,7 @@ async def update_target_project( 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 TargetProject. @@ -5520,8 +5636,10 @@ async def sample_update_target_project(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -5596,7 +5714,7 @@ async def delete_target_project( name: Optional[str] = None, retry: OptionalRetry = gapic_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 TargetProject. @@ -5645,8 +5763,10 @@ async def sample_delete_target_project(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -5725,7 +5845,7 @@ async def list_replication_cycles( 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.ListReplicationCyclesAsyncPager: r"""Lists ReplicationCycles in a given MigratingVM. @@ -5771,8 +5891,10 @@ async def sample_list_replication_cycles(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListReplicationCyclesAsyncPager: @@ -5847,7 +5969,7 @@ async def get_replication_cycle( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.ReplicationCycle: r"""Gets details of a single ReplicationCycle. @@ -5891,8 +6013,10 @@ async def sample_get_replication_cycle(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmmigration_v1.types.ReplicationCycle: @@ -5953,7 +6077,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. @@ -5964,8 +6088,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. @@ -6006,7 +6132,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. @@ -6017,8 +6143,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. @@ -6059,7 +6187,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. @@ -6075,8 +6203,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 """ @@ -6113,7 +6243,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. @@ -6128,8 +6258,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 """ @@ -6166,7 +6298,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. @@ -6177,8 +6309,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. @@ -6219,7 +6353,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. @@ -6230,8 +6364,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-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/client.py b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/client.py index c7e43a649594..ca8e099c82d6 100644 --- a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/client.py +++ b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/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 @@ -782,6 +792,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( @@ -844,6 +858,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.vmmigration_v1.VmMigrationClient`.", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "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.vmmigration.v1.VmMigration", + "credentialsType": None, + }, + ) + def list_sources( self, request: Optional[Union[vmmigration.ListSourcesRequest, dict]] = None, @@ -851,7 +888,7 @@ def list_sources( 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.ListSourcesPager: r"""Lists Sources in a given project and location. @@ -897,8 +934,10 @@ def sample_list_sources(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListSourcesPager: @@ -970,7 +1009,7 @@ def get_source( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.Source: r"""Gets details of a single Source. @@ -1012,8 +1051,10 @@ def sample_get_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.cloud.vmmigration_v1.types.Source: @@ -1075,7 +1116,7 @@ def create_source( source_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 Source in a given project and location. @@ -1132,8 +1173,10 @@ def sample_create_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: @@ -1206,7 +1249,7 @@ def update_source( 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 Source. @@ -1262,8 +1305,10 @@ def sample_update_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: @@ -1335,7 +1380,7 @@ def delete_source( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Source. @@ -1381,8 +1426,10 @@ def sample_delete_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: @@ -1458,7 +1505,7 @@ def fetch_inventory( source: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.FetchInventoryResponse: r"""List remote source's inventory of VMs. The remote source is the onprem vCenter (remote in the @@ -1506,8 +1553,10 @@ def sample_fetch_inventory(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmmigration_v1.types.FetchInventoryResponse: @@ -1567,7 +1616,7 @@ def list_utilization_reports( 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.ListUtilizationReportsPager: r"""Lists Utilization Reports of the given Source. @@ -1613,8 +1662,10 @@ def sample_list_utilization_reports(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListUtilizationReportsPager: @@ -1686,7 +1737,7 @@ def get_utilization_report( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.UtilizationReport: r"""Gets a single Utilization Report. @@ -1730,8 +1781,10 @@ def sample_get_utilization_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.vmmigration_v1.types.UtilizationReport: @@ -1794,7 +1847,7 @@ def create_utilization_report( utilization_report_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 UtilizationReport. @@ -1860,8 +1913,10 @@ def sample_create_utilization_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.api_core.operation.Operation: @@ -1937,7 +1992,7 @@ def delete_utilization_report( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Utilization Report. @@ -1985,8 +2040,10 @@ def sample_delete_utilization_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.api_core.operation.Operation: @@ -2066,7 +2123,7 @@ def list_datacenter_connectors( 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.ListDatacenterConnectorsPager: r"""Lists DatacenterConnectors in a given Source. @@ -2112,8 +2169,10 @@ def sample_list_datacenter_connectors(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListDatacenterConnectorsPager: @@ -2189,7 +2248,7 @@ def get_datacenter_connector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.DatacenterConnector: r"""Gets details of a single DatacenterConnector. @@ -2233,8 +2292,10 @@ def sample_get_datacenter_connector(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmmigration_v1.types.DatacenterConnector: @@ -2301,7 +2362,7 @@ def create_datacenter_connector( datacenter_connector_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 DatacenterConnector in a given Source. @@ -2364,8 +2425,10 @@ def sample_create_datacenter_connector(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2446,7 +2509,7 @@ def delete_datacenter_connector( name: Optional[str] = None, retry: OptionalRetry = gapic_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 DatacenterConnector. @@ -2494,8 +2557,10 @@ def sample_delete_datacenter_connector(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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 +2637,7 @@ def upgrade_appliance( *, retry: OptionalRetry = gapic_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"""Upgrades the appliance relate to this DatacenterConnector to the in-place updateable version. @@ -2614,8 +2679,10 @@ def sample_upgrade_appliance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2675,7 +2742,7 @@ def create_migrating_vm( migrating_vm_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 MigratingVm in a given Source. @@ -2732,8 +2799,10 @@ def sample_create_migrating_vm(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2805,7 +2874,7 @@ def list_migrating_vms( 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.ListMigratingVmsPager: r"""Lists MigratingVms in a given Source. @@ -2851,8 +2920,10 @@ def sample_list_migrating_vms(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListMigratingVmsPager: @@ -2924,7 +2995,7 @@ def get_migrating_vm( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.MigratingVm: r"""Gets details of a single MigratingVm. @@ -2968,8 +3039,10 @@ def sample_get_migrating_vm(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmmigration_v1.types.MigratingVm: @@ -3029,7 +3102,7 @@ def update_migrating_vm( 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 MigratingVm. @@ -3085,8 +3158,10 @@ def sample_update_migrating_vm(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3158,7 +3233,7 @@ def delete_migrating_vm( name: Optional[str] = None, retry: OptionalRetry = gapic_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 MigratingVm. @@ -3206,8 +3281,10 @@ def sample_delete_migrating_vm(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3283,7 +3360,7 @@ def start_migration( migrating_vm: Optional[str] = None, retry: OptionalRetry = gapic_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"""Starts migration for a VM. Starts the process of uploading data and creating snapshots, in replication @@ -3333,8 +3410,10 @@ def sample_start_migration(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3404,7 +3483,7 @@ def resume_migration( *, retry: OptionalRetry = gapic_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"""Resumes a migration for a VM. When called on a paused migration, will start the process of uploading data and @@ -3450,8 +3529,10 @@ def sample_resume_migration(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3508,7 +3589,7 @@ def pause_migration( *, retry: OptionalRetry = gapic_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"""Pauses a migration for a VM. If cycle tasks are running they will be cancelled, preserving source task @@ -3552,8 +3633,10 @@ def sample_pause_migration(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3611,7 +3694,7 @@ def finalize_migration( migrating_vm: Optional[str] = None, retry: OptionalRetry = gapic_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"""Marks a migration as completed, deleting migration resources that are no longer being used. Only applicable @@ -3661,8 +3744,10 @@ def sample_finalize_migration(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3735,7 +3820,7 @@ def create_clone_job( clone_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]]] = (), ) -> operation.Operation: r"""Initiates a Clone of a specific migrating VM. @@ -3792,8 +3877,10 @@ def sample_create_clone_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: @@ -3877,7 +3964,7 @@ def cancel_clone_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"""Initiates the cancellation of a running clone job. @@ -3923,8 +4010,10 @@ def sample_cancel_clone_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: @@ -3993,7 +4082,7 @@ def list_clone_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.ListCloneJobsPager: r"""Lists CloneJobs of a given migrating VM. @@ -4039,8 +4128,10 @@ def sample_list_clone_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.vmmigration_v1.services.vm_migration.pagers.ListCloneJobsPager: @@ -4112,7 +4203,7 @@ def get_clone_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]]] = (), ) -> vmmigration.CloneJob: r"""Gets details of a single CloneJob. @@ -4154,8 +4245,10 @@ def sample_get_clone_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.vmmigration_v1.types.CloneJob: @@ -4227,7 +4320,7 @@ def create_cutover_job( cutover_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]]] = (), ) -> operation.Operation: r"""Initiates a Cutover of a specific migrating VM. The returned LRO is completed when the cutover job @@ -4286,8 +4379,10 @@ def sample_create_cutover_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: @@ -4361,7 +4456,7 @@ def cancel_cutover_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"""Initiates the cancellation of a running cutover job. @@ -4407,8 +4502,10 @@ def sample_cancel_cutover_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: @@ -4477,7 +4574,7 @@ def list_cutover_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.ListCutoverJobsPager: r"""Lists CutoverJobs of a given migrating VM. @@ -4523,8 +4620,10 @@ def sample_list_cutover_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.vmmigration_v1.services.vm_migration.pagers.ListCutoverJobsPager: @@ -4596,7 +4695,7 @@ def get_cutover_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]]] = (), ) -> vmmigration.CutoverJob: r"""Gets details of a single CutoverJob. @@ -4638,8 +4737,10 @@ def sample_get_cutover_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.vmmigration_v1.types.CutoverJob: @@ -4701,7 +4802,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 project and location. @@ -4747,8 +4848,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.vmmigration_v1.services.vm_migration.pagers.ListGroupsPager: @@ -4820,7 +4923,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]]] = (), ) -> vmmigration.Group: r"""Gets details of a single Group. @@ -4862,8 +4965,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.vmmigration_v1.types.Group: @@ -4924,7 +5029,7 @@ def create_group( group_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 Group in a given project and location. @@ -4981,8 +5086,10 @@ def sample_create_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.api_core.operation.Operation: @@ -5055,7 +5162,7 @@ def update_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]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Group. @@ -5111,8 +5218,10 @@ def sample_update_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.api_core.operation.Operation: @@ -5184,7 +5293,7 @@ def delete_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]]] = (), ) -> operation.Operation: r"""Deletes a single Group. @@ -5230,8 +5339,10 @@ def sample_delete_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.api_core.operation.Operation: @@ -5307,7 +5418,7 @@ def add_group_migration( 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]]] = (), ) -> operation.Operation: r"""Adds a MigratingVm to a Group. @@ -5355,8 +5466,10 @@ def sample_add_group_migration(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -5425,7 +5538,7 @@ def remove_group_migration( 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]]] = (), ) -> operation.Operation: r"""Removes a MigratingVm from a Group. @@ -5471,8 +5584,10 @@ def sample_remove_group_migration(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -5541,7 +5656,7 @@ def list_target_projects( 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.ListTargetProjectsPager: r"""Lists TargetProjects in a given project. @@ -5590,8 +5705,10 @@ def sample_list_target_projects(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListTargetProjectsPager: @@ -5663,7 +5780,7 @@ def get_target_project( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.TargetProject: r"""Gets details of a single TargetProject. @@ -5708,8 +5825,10 @@ def sample_get_target_project(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmmigration_v1.types.TargetProject: @@ -5770,7 +5889,7 @@ def create_target_project( target_project_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 TargetProject in a given project. @@ -5830,8 +5949,10 @@ def sample_create_target_project(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -5904,7 +6025,7 @@ def update_target_project( 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 TargetProject. @@ -5963,8 +6084,10 @@ def sample_update_target_project(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -6036,7 +6159,7 @@ def delete_target_project( name: Optional[str] = None, retry: OptionalRetry = gapic_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 TargetProject. @@ -6085,8 +6208,10 @@ def sample_delete_target_project(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -6162,7 +6287,7 @@ def list_replication_cycles( 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.ListReplicationCyclesPager: r"""Lists ReplicationCycles in a given MigratingVM. @@ -6208,8 +6333,10 @@ def sample_list_replication_cycles(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListReplicationCyclesPager: @@ -6281,7 +6408,7 @@ def get_replication_cycle( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.ReplicationCycle: r"""Gets details of a single ReplicationCycle. @@ -6325,8 +6452,10 @@ def sample_get_replication_cycle(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmmigration_v1.types.ReplicationCycle: @@ -6397,7 +6526,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. @@ -6408,8 +6537,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. @@ -6450,7 +6581,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. @@ -6461,8 +6592,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. @@ -6503,7 +6636,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. @@ -6519,8 +6652,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 """ @@ -6557,7 +6692,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. @@ -6572,8 +6707,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 """ @@ -6610,7 +6747,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. @@ -6621,8 +6758,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. @@ -6663,7 +6802,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. @@ -6674,8 +6813,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-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/pagers.py b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/pagers.py index 83940db79a3f..8ba44e197d7d 100644 --- a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/pagers.py +++ b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/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 = vmmigration.ListSourcesRequest(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 = vmmigration.ListSourcesRequest(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 = vmmigration.ListUtilizationReportsRequest(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 = vmmigration.ListUtilizationReportsRequest(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 = vmmigration.ListDatacenterConnectorsRequest(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 = vmmigration.ListDatacenterConnectorsRequest(request) @@ -525,7 +537,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -539,8 +551,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = vmmigration.ListMigratingVmsRequest(request) @@ -599,7 +613,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. @@ -613,8 +627,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 = vmmigration.ListMigratingVmsRequest(request) @@ -677,7 +693,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -691,8 +707,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = vmmigration.ListCloneJobsRequest(request) @@ -751,7 +769,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. @@ -765,8 +783,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 = vmmigration.ListCloneJobsRequest(request) @@ -829,7 +849,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -843,8 +863,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = vmmigration.ListCutoverJobsRequest(request) @@ -903,7 +925,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. @@ -917,8 +939,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 = vmmigration.ListCutoverJobsRequest(request) @@ -981,7 +1005,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -995,8 +1019,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = vmmigration.ListGroupsRequest(request) @@ -1055,7 +1081,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. @@ -1069,8 +1095,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 = vmmigration.ListGroupsRequest(request) @@ -1133,7 +1161,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1147,8 +1175,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = vmmigration.ListTargetProjectsRequest(request) @@ -1207,7 +1237,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. @@ -1221,8 +1251,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 = vmmigration.ListTargetProjectsRequest(request) @@ -1285,7 +1317,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1299,8 +1331,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = vmmigration.ListReplicationCyclesRequest(request) @@ -1359,7 +1393,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. @@ -1373,8 +1407,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 = vmmigration.ListReplicationCyclesRequest(request) diff --git a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/transports/grpc.py b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/transports/grpc.py index fb43a9ee7153..3cabc8d8399d 100644 --- a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/transports/grpc.py +++ b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/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.vmmigration_v1.types import vmmigration from .base import DEFAULT_CLIENT_INFO, VmMigrationTransport +try: + from google.api_core import client_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.vmmigration.v1.VmMigration", + "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.vmmigration.v1.VmMigration", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VmMigrationGrpcTransport(VmMigrationTransport): """gRPC backend transport for VmMigration. @@ -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 @@ -272,7 +360,7 @@ def list_sources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_sources" not in self._stubs: - self._stubs["list_sources"] = self.grpc_channel.unary_unary( + self._stubs["list_sources"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListSources", request_serializer=vmmigration.ListSourcesRequest.serialize, response_deserializer=vmmigration.ListSourcesResponse.deserialize, @@ -298,7 +386,7 @@ def get_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_source" not in self._stubs: - self._stubs["get_source"] = self.grpc_channel.unary_unary( + self._stubs["get_source"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetSource", request_serializer=vmmigration.GetSourceRequest.serialize, response_deserializer=vmmigration.Source.deserialize, @@ -324,7 +412,7 @@ def create_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_source" not in self._stubs: - self._stubs["create_source"] = self.grpc_channel.unary_unary( + self._stubs["create_source"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateSource", request_serializer=vmmigration.CreateSourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -350,7 +438,7 @@ def update_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_source" not in self._stubs: - self._stubs["update_source"] = self.grpc_channel.unary_unary( + self._stubs["update_source"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/UpdateSource", request_serializer=vmmigration.UpdateSourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -376,7 +464,7 @@ def delete_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_source" not in self._stubs: - self._stubs["delete_source"] = self.grpc_channel.unary_unary( + self._stubs["delete_source"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/DeleteSource", request_serializer=vmmigration.DeleteSourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -410,7 +498,7 @@ def fetch_inventory( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "fetch_inventory" not in self._stubs: - self._stubs["fetch_inventory"] = self.grpc_channel.unary_unary( + self._stubs["fetch_inventory"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/FetchInventory", request_serializer=vmmigration.FetchInventoryRequest.serialize, response_deserializer=vmmigration.FetchInventoryResponse.deserialize, @@ -439,7 +527,7 @@ def list_utilization_reports( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_utilization_reports" not in self._stubs: - self._stubs["list_utilization_reports"] = self.grpc_channel.unary_unary( + self._stubs["list_utilization_reports"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListUtilizationReports", request_serializer=vmmigration.ListUtilizationReportsRequest.serialize, response_deserializer=vmmigration.ListUtilizationReportsResponse.deserialize, @@ -467,7 +555,7 @@ def get_utilization_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_utilization_report" not in self._stubs: - self._stubs["get_utilization_report"] = self.grpc_channel.unary_unary( + self._stubs["get_utilization_report"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetUtilizationReport", request_serializer=vmmigration.GetUtilizationReportRequest.serialize, response_deserializer=vmmigration.UtilizationReport.deserialize, @@ -495,7 +583,7 @@ def create_utilization_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_utilization_report" not in self._stubs: - self._stubs["create_utilization_report"] = self.grpc_channel.unary_unary( + self._stubs["create_utilization_report"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateUtilizationReport", request_serializer=vmmigration.CreateUtilizationReportRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -523,7 +611,7 @@ def delete_utilization_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_utilization_report" not in self._stubs: - self._stubs["delete_utilization_report"] = self.grpc_channel.unary_unary( + self._stubs["delete_utilization_report"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/DeleteUtilizationReport", request_serializer=vmmigration.DeleteUtilizationReportRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -552,7 +640,9 @@ def list_datacenter_connectors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_datacenter_connectors" not in self._stubs: - self._stubs["list_datacenter_connectors"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_datacenter_connectors" + ] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListDatacenterConnectors", request_serializer=vmmigration.ListDatacenterConnectorsRequest.serialize, response_deserializer=vmmigration.ListDatacenterConnectorsResponse.deserialize, @@ -580,7 +670,7 @@ def get_datacenter_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_datacenter_connector" not in self._stubs: - self._stubs["get_datacenter_connector"] = self.grpc_channel.unary_unary( + self._stubs["get_datacenter_connector"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetDatacenterConnector", request_serializer=vmmigration.GetDatacenterConnectorRequest.serialize, response_deserializer=vmmigration.DatacenterConnector.deserialize, @@ -608,7 +698,9 @@ def create_datacenter_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_datacenter_connector" not in self._stubs: - self._stubs["create_datacenter_connector"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_datacenter_connector" + ] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateDatacenterConnector", request_serializer=vmmigration.CreateDatacenterConnectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -636,7 +728,9 @@ def delete_datacenter_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_datacenter_connector" not in self._stubs: - self._stubs["delete_datacenter_connector"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_datacenter_connector" + ] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/DeleteDatacenterConnector", request_serializer=vmmigration.DeleteDatacenterConnectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -663,7 +757,7 @@ def upgrade_appliance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "upgrade_appliance" not in self._stubs: - self._stubs["upgrade_appliance"] = self.grpc_channel.unary_unary( + self._stubs["upgrade_appliance"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/UpgradeAppliance", request_serializer=vmmigration.UpgradeApplianceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -689,7 +783,7 @@ def create_migrating_vm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_migrating_vm" not in self._stubs: - self._stubs["create_migrating_vm"] = self.grpc_channel.unary_unary( + self._stubs["create_migrating_vm"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateMigratingVm", request_serializer=vmmigration.CreateMigratingVmRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -717,7 +811,7 @@ def list_migrating_vms( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_migrating_vms" not in self._stubs: - self._stubs["list_migrating_vms"] = self.grpc_channel.unary_unary( + self._stubs["list_migrating_vms"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListMigratingVms", request_serializer=vmmigration.ListMigratingVmsRequest.serialize, response_deserializer=vmmigration.ListMigratingVmsResponse.deserialize, @@ -743,7 +837,7 @@ def get_migrating_vm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_migrating_vm" not in self._stubs: - self._stubs["get_migrating_vm"] = self.grpc_channel.unary_unary( + self._stubs["get_migrating_vm"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetMigratingVm", request_serializer=vmmigration.GetMigratingVmRequest.serialize, response_deserializer=vmmigration.MigratingVm.deserialize, @@ -769,7 +863,7 @@ def update_migrating_vm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_migrating_vm" not in self._stubs: - self._stubs["update_migrating_vm"] = self.grpc_channel.unary_unary( + self._stubs["update_migrating_vm"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/UpdateMigratingVm", request_serializer=vmmigration.UpdateMigratingVmRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -795,7 +889,7 @@ def delete_migrating_vm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_migrating_vm" not in self._stubs: - self._stubs["delete_migrating_vm"] = self.grpc_channel.unary_unary( + self._stubs["delete_migrating_vm"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/DeleteMigratingVm", request_serializer=vmmigration.DeleteMigratingVmRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -823,7 +917,7 @@ def start_migration( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_migration" not in self._stubs: - self._stubs["start_migration"] = self.grpc_channel.unary_unary( + self._stubs["start_migration"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/StartMigration", request_serializer=vmmigration.StartMigrationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -854,7 +948,7 @@ def resume_migration( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_migration" not in self._stubs: - self._stubs["resume_migration"] = self.grpc_channel.unary_unary( + self._stubs["resume_migration"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ResumeMigration", request_serializer=vmmigration.ResumeMigrationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -883,7 +977,7 @@ def pause_migration( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_migration" not in self._stubs: - self._stubs["pause_migration"] = self.grpc_channel.unary_unary( + self._stubs["pause_migration"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/PauseMigration", request_serializer=vmmigration.PauseMigrationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -911,7 +1005,7 @@ def finalize_migration( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "finalize_migration" not in self._stubs: - self._stubs["finalize_migration"] = self.grpc_channel.unary_unary( + self._stubs["finalize_migration"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/FinalizeMigration", request_serializer=vmmigration.FinalizeMigrationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -937,7 +1031,7 @@ def create_clone_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_clone_job" not in self._stubs: - self._stubs["create_clone_job"] = self.grpc_channel.unary_unary( + self._stubs["create_clone_job"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateCloneJob", request_serializer=vmmigration.CreateCloneJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -963,7 +1057,7 @@ def cancel_clone_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_clone_job" not in self._stubs: - self._stubs["cancel_clone_job"] = self.grpc_channel.unary_unary( + self._stubs["cancel_clone_job"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CancelCloneJob", request_serializer=vmmigration.CancelCloneJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -991,7 +1085,7 @@ def list_clone_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_clone_jobs" not in self._stubs: - self._stubs["list_clone_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_clone_jobs"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListCloneJobs", request_serializer=vmmigration.ListCloneJobsRequest.serialize, response_deserializer=vmmigration.ListCloneJobsResponse.deserialize, @@ -1017,7 +1111,7 @@ def get_clone_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_clone_job" not in self._stubs: - self._stubs["get_clone_job"] = self.grpc_channel.unary_unary( + self._stubs["get_clone_job"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetCloneJob", request_serializer=vmmigration.GetCloneJobRequest.serialize, response_deserializer=vmmigration.CloneJob.deserialize, @@ -1045,7 +1139,7 @@ def create_cutover_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_cutover_job" not in self._stubs: - self._stubs["create_cutover_job"] = self.grpc_channel.unary_unary( + self._stubs["create_cutover_job"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateCutoverJob", request_serializer=vmmigration.CreateCutoverJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1071,7 +1165,7 @@ def cancel_cutover_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_cutover_job" not in self._stubs: - self._stubs["cancel_cutover_job"] = self.grpc_channel.unary_unary( + self._stubs["cancel_cutover_job"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CancelCutoverJob", request_serializer=vmmigration.CancelCutoverJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1099,7 +1193,7 @@ def list_cutover_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_cutover_jobs" not in self._stubs: - self._stubs["list_cutover_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_cutover_jobs"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListCutoverJobs", request_serializer=vmmigration.ListCutoverJobsRequest.serialize, response_deserializer=vmmigration.ListCutoverJobsResponse.deserialize, @@ -1125,7 +1219,7 @@ def get_cutover_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_cutover_job" not in self._stubs: - self._stubs["get_cutover_job"] = self.grpc_channel.unary_unary( + self._stubs["get_cutover_job"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetCutoverJob", request_serializer=vmmigration.GetCutoverJobRequest.serialize, response_deserializer=vmmigration.CutoverJob.deserialize, @@ -1151,7 +1245,7 @@ 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.vmmigration.v1.VmMigration/ListGroups", request_serializer=vmmigration.ListGroupsRequest.serialize, response_deserializer=vmmigration.ListGroupsResponse.deserialize, @@ -1175,7 +1269,7 @@ def get_group(self) -> Callable[[vmmigration.GetGroupRequest], vmmigration.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.vmmigration.v1.VmMigration/GetGroup", request_serializer=vmmigration.GetGroupRequest.serialize, response_deserializer=vmmigration.Group.deserialize, @@ -1201,7 +1295,7 @@ def create_group( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_group" not in self._stubs: - self._stubs["create_group"] = self.grpc_channel.unary_unary( + self._stubs["create_group"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateGroup", request_serializer=vmmigration.CreateGroupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1227,7 +1321,7 @@ def update_group( # 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.grpc_channel.unary_unary( + self._stubs["update_group"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/UpdateGroup", request_serializer=vmmigration.UpdateGroupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1253,7 +1347,7 @@ def delete_group( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_group" not in self._stubs: - self._stubs["delete_group"] = self.grpc_channel.unary_unary( + self._stubs["delete_group"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/DeleteGroup", request_serializer=vmmigration.DeleteGroupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1279,7 +1373,7 @@ def add_group_migration( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_group_migration" not in self._stubs: - self._stubs["add_group_migration"] = self.grpc_channel.unary_unary( + self._stubs["add_group_migration"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/AddGroupMigration", request_serializer=vmmigration.AddGroupMigrationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1305,7 +1399,7 @@ def remove_group_migration( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_group_migration" not in self._stubs: - self._stubs["remove_group_migration"] = self.grpc_channel.unary_unary( + self._stubs["remove_group_migration"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/RemoveGroupMigration", request_serializer=vmmigration.RemoveGroupMigrationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1336,7 +1430,7 @@ def list_target_projects( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_target_projects" not in self._stubs: - self._stubs["list_target_projects"] = self.grpc_channel.unary_unary( + self._stubs["list_target_projects"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListTargetProjects", request_serializer=vmmigration.ListTargetProjectsRequest.serialize, response_deserializer=vmmigration.ListTargetProjectsResponse.deserialize, @@ -1365,7 +1459,7 @@ def get_target_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_target_project" not in self._stubs: - self._stubs["get_target_project"] = self.grpc_channel.unary_unary( + self._stubs["get_target_project"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetTargetProject", request_serializer=vmmigration.GetTargetProjectRequest.serialize, response_deserializer=vmmigration.TargetProject.deserialize, @@ -1394,7 +1488,7 @@ def create_target_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_target_project" not in self._stubs: - self._stubs["create_target_project"] = self.grpc_channel.unary_unary( + self._stubs["create_target_project"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateTargetProject", request_serializer=vmmigration.CreateTargetProjectRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1423,7 +1517,7 @@ def update_target_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_target_project" not in self._stubs: - self._stubs["update_target_project"] = self.grpc_channel.unary_unary( + self._stubs["update_target_project"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/UpdateTargetProject", request_serializer=vmmigration.UpdateTargetProjectRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1452,7 +1546,7 @@ def delete_target_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_target_project" not in self._stubs: - self._stubs["delete_target_project"] = self.grpc_channel.unary_unary( + self._stubs["delete_target_project"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/DeleteTargetProject", request_serializer=vmmigration.DeleteTargetProjectRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1481,7 +1575,7 @@ def list_replication_cycles( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_replication_cycles" not in self._stubs: - self._stubs["list_replication_cycles"] = self.grpc_channel.unary_unary( + self._stubs["list_replication_cycles"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListReplicationCycles", request_serializer=vmmigration.ListReplicationCyclesRequest.serialize, response_deserializer=vmmigration.ListReplicationCyclesResponse.deserialize, @@ -1509,7 +1603,7 @@ def get_replication_cycle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_replication_cycle" not in self._stubs: - self._stubs["get_replication_cycle"] = self.grpc_channel.unary_unary( + self._stubs["get_replication_cycle"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetReplicationCycle", request_serializer=vmmigration.GetReplicationCycleRequest.serialize, response_deserializer=vmmigration.ReplicationCycle.deserialize, @@ -1517,7 +1611,7 @@ def get_replication_cycle( return self._stubs["get_replication_cycle"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -1529,7 +1623,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, @@ -1546,7 +1640,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, @@ -1563,7 +1657,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, @@ -1582,7 +1676,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, @@ -1601,7 +1695,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, @@ -1618,7 +1712,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-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/transports/grpc_asyncio.py b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/transports/grpc_asyncio.py index aa1c2979d7d5..2a87d0a2372f 100644 --- a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/transports/grpc_asyncio.py +++ b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/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.vmmigration_v1.types import vmmigration from .base import DEFAULT_CLIENT_INFO, VmMigrationTransport from .grpc import VmMigrationGrpcTransport +try: + from google.api_core import client_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.vmmigration.v1.VmMigration", + "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.vmmigration.v1.VmMigration", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VmMigrationGrpcAsyncIOTransport(VmMigrationTransport): """gRPC AsyncIO backend transport for VmMigration. @@ -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. @@ -284,7 +369,7 @@ def list_sources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_sources" not in self._stubs: - self._stubs["list_sources"] = self.grpc_channel.unary_unary( + self._stubs["list_sources"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListSources", request_serializer=vmmigration.ListSourcesRequest.serialize, response_deserializer=vmmigration.ListSourcesResponse.deserialize, @@ -310,7 +395,7 @@ def get_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_source" not in self._stubs: - self._stubs["get_source"] = self.grpc_channel.unary_unary( + self._stubs["get_source"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetSource", request_serializer=vmmigration.GetSourceRequest.serialize, response_deserializer=vmmigration.Source.deserialize, @@ -338,7 +423,7 @@ def create_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_source" not in self._stubs: - self._stubs["create_source"] = self.grpc_channel.unary_unary( + self._stubs["create_source"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateSource", request_serializer=vmmigration.CreateSourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -366,7 +451,7 @@ def update_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_source" not in self._stubs: - self._stubs["update_source"] = self.grpc_channel.unary_unary( + self._stubs["update_source"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/UpdateSource", request_serializer=vmmigration.UpdateSourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -394,7 +479,7 @@ def delete_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_source" not in self._stubs: - self._stubs["delete_source"] = self.grpc_channel.unary_unary( + self._stubs["delete_source"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/DeleteSource", request_serializer=vmmigration.DeleteSourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -429,7 +514,7 @@ def fetch_inventory( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "fetch_inventory" not in self._stubs: - self._stubs["fetch_inventory"] = self.grpc_channel.unary_unary( + self._stubs["fetch_inventory"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/FetchInventory", request_serializer=vmmigration.FetchInventoryRequest.serialize, response_deserializer=vmmigration.FetchInventoryResponse.deserialize, @@ -458,7 +543,7 @@ def list_utilization_reports( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_utilization_reports" not in self._stubs: - self._stubs["list_utilization_reports"] = self.grpc_channel.unary_unary( + self._stubs["list_utilization_reports"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListUtilizationReports", request_serializer=vmmigration.ListUtilizationReportsRequest.serialize, response_deserializer=vmmigration.ListUtilizationReportsResponse.deserialize, @@ -487,7 +572,7 @@ def get_utilization_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_utilization_report" not in self._stubs: - self._stubs["get_utilization_report"] = self.grpc_channel.unary_unary( + self._stubs["get_utilization_report"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetUtilizationReport", request_serializer=vmmigration.GetUtilizationReportRequest.serialize, response_deserializer=vmmigration.UtilizationReport.deserialize, @@ -516,7 +601,7 @@ def create_utilization_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_utilization_report" not in self._stubs: - self._stubs["create_utilization_report"] = self.grpc_channel.unary_unary( + self._stubs["create_utilization_report"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateUtilizationReport", request_serializer=vmmigration.CreateUtilizationReportRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -545,7 +630,7 @@ def delete_utilization_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_utilization_report" not in self._stubs: - self._stubs["delete_utilization_report"] = self.grpc_channel.unary_unary( + self._stubs["delete_utilization_report"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/DeleteUtilizationReport", request_serializer=vmmigration.DeleteUtilizationReportRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -574,7 +659,9 @@ def list_datacenter_connectors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_datacenter_connectors" not in self._stubs: - self._stubs["list_datacenter_connectors"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_datacenter_connectors" + ] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListDatacenterConnectors", request_serializer=vmmigration.ListDatacenterConnectorsRequest.serialize, response_deserializer=vmmigration.ListDatacenterConnectorsResponse.deserialize, @@ -603,7 +690,7 @@ def get_datacenter_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_datacenter_connector" not in self._stubs: - self._stubs["get_datacenter_connector"] = self.grpc_channel.unary_unary( + self._stubs["get_datacenter_connector"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetDatacenterConnector", request_serializer=vmmigration.GetDatacenterConnectorRequest.serialize, response_deserializer=vmmigration.DatacenterConnector.deserialize, @@ -632,7 +719,9 @@ def create_datacenter_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_datacenter_connector" not in self._stubs: - self._stubs["create_datacenter_connector"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_datacenter_connector" + ] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateDatacenterConnector", request_serializer=vmmigration.CreateDatacenterConnectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -661,7 +750,9 @@ def delete_datacenter_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_datacenter_connector" not in self._stubs: - self._stubs["delete_datacenter_connector"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_datacenter_connector" + ] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/DeleteDatacenterConnector", request_serializer=vmmigration.DeleteDatacenterConnectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -690,7 +781,7 @@ def upgrade_appliance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "upgrade_appliance" not in self._stubs: - self._stubs["upgrade_appliance"] = self.grpc_channel.unary_unary( + self._stubs["upgrade_appliance"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/UpgradeAppliance", request_serializer=vmmigration.UpgradeApplianceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -718,7 +809,7 @@ def create_migrating_vm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_migrating_vm" not in self._stubs: - self._stubs["create_migrating_vm"] = self.grpc_channel.unary_unary( + self._stubs["create_migrating_vm"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateMigratingVm", request_serializer=vmmigration.CreateMigratingVmRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -747,7 +838,7 @@ def list_migrating_vms( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_migrating_vms" not in self._stubs: - self._stubs["list_migrating_vms"] = self.grpc_channel.unary_unary( + self._stubs["list_migrating_vms"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListMigratingVms", request_serializer=vmmigration.ListMigratingVmsRequest.serialize, response_deserializer=vmmigration.ListMigratingVmsResponse.deserialize, @@ -775,7 +866,7 @@ def get_migrating_vm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_migrating_vm" not in self._stubs: - self._stubs["get_migrating_vm"] = self.grpc_channel.unary_unary( + self._stubs["get_migrating_vm"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetMigratingVm", request_serializer=vmmigration.GetMigratingVmRequest.serialize, response_deserializer=vmmigration.MigratingVm.deserialize, @@ -803,7 +894,7 @@ def update_migrating_vm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_migrating_vm" not in self._stubs: - self._stubs["update_migrating_vm"] = self.grpc_channel.unary_unary( + self._stubs["update_migrating_vm"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/UpdateMigratingVm", request_serializer=vmmigration.UpdateMigratingVmRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -831,7 +922,7 @@ def delete_migrating_vm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_migrating_vm" not in self._stubs: - self._stubs["delete_migrating_vm"] = self.grpc_channel.unary_unary( + self._stubs["delete_migrating_vm"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/DeleteMigratingVm", request_serializer=vmmigration.DeleteMigratingVmRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -861,7 +952,7 @@ def start_migration( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_migration" not in self._stubs: - self._stubs["start_migration"] = self.grpc_channel.unary_unary( + self._stubs["start_migration"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/StartMigration", request_serializer=vmmigration.StartMigrationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -894,7 +985,7 @@ def resume_migration( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_migration" not in self._stubs: - self._stubs["resume_migration"] = self.grpc_channel.unary_unary( + self._stubs["resume_migration"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ResumeMigration", request_serializer=vmmigration.ResumeMigrationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -925,7 +1016,7 @@ def pause_migration( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_migration" not in self._stubs: - self._stubs["pause_migration"] = self.grpc_channel.unary_unary( + self._stubs["pause_migration"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/PauseMigration", request_serializer=vmmigration.PauseMigrationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -955,7 +1046,7 @@ def finalize_migration( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "finalize_migration" not in self._stubs: - self._stubs["finalize_migration"] = self.grpc_channel.unary_unary( + self._stubs["finalize_migration"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/FinalizeMigration", request_serializer=vmmigration.FinalizeMigrationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -983,7 +1074,7 @@ def create_clone_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_clone_job" not in self._stubs: - self._stubs["create_clone_job"] = self.grpc_channel.unary_unary( + self._stubs["create_clone_job"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateCloneJob", request_serializer=vmmigration.CreateCloneJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1011,7 +1102,7 @@ def cancel_clone_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_clone_job" not in self._stubs: - self._stubs["cancel_clone_job"] = self.grpc_channel.unary_unary( + self._stubs["cancel_clone_job"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CancelCloneJob", request_serializer=vmmigration.CancelCloneJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1039,7 +1130,7 @@ def list_clone_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_clone_jobs" not in self._stubs: - self._stubs["list_clone_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_clone_jobs"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListCloneJobs", request_serializer=vmmigration.ListCloneJobsRequest.serialize, response_deserializer=vmmigration.ListCloneJobsResponse.deserialize, @@ -1065,7 +1156,7 @@ def get_clone_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_clone_job" not in self._stubs: - self._stubs["get_clone_job"] = self.grpc_channel.unary_unary( + self._stubs["get_clone_job"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetCloneJob", request_serializer=vmmigration.GetCloneJobRequest.serialize, response_deserializer=vmmigration.CloneJob.deserialize, @@ -1095,7 +1186,7 @@ def create_cutover_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_cutover_job" not in self._stubs: - self._stubs["create_cutover_job"] = self.grpc_channel.unary_unary( + self._stubs["create_cutover_job"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateCutoverJob", request_serializer=vmmigration.CreateCutoverJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1123,7 +1214,7 @@ def cancel_cutover_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_cutover_job" not in self._stubs: - self._stubs["cancel_cutover_job"] = self.grpc_channel.unary_unary( + self._stubs["cancel_cutover_job"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CancelCutoverJob", request_serializer=vmmigration.CancelCutoverJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1152,7 +1243,7 @@ def list_cutover_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_cutover_jobs" not in self._stubs: - self._stubs["list_cutover_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_cutover_jobs"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListCutoverJobs", request_serializer=vmmigration.ListCutoverJobsRequest.serialize, response_deserializer=vmmigration.ListCutoverJobsResponse.deserialize, @@ -1180,7 +1271,7 @@ def get_cutover_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_cutover_job" not in self._stubs: - self._stubs["get_cutover_job"] = self.grpc_channel.unary_unary( + self._stubs["get_cutover_job"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetCutoverJob", request_serializer=vmmigration.GetCutoverJobRequest.serialize, response_deserializer=vmmigration.CutoverJob.deserialize, @@ -1208,7 +1299,7 @@ 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.vmmigration.v1.VmMigration/ListGroups", request_serializer=vmmigration.ListGroupsRequest.serialize, response_deserializer=vmmigration.ListGroupsResponse.deserialize, @@ -1234,7 +1325,7 @@ def get_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.vmmigration.v1.VmMigration/GetGroup", request_serializer=vmmigration.GetGroupRequest.serialize, response_deserializer=vmmigration.Group.deserialize, @@ -1262,7 +1353,7 @@ def create_group( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_group" not in self._stubs: - self._stubs["create_group"] = self.grpc_channel.unary_unary( + self._stubs["create_group"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateGroup", request_serializer=vmmigration.CreateGroupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1290,7 +1381,7 @@ def update_group( # 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.grpc_channel.unary_unary( + self._stubs["update_group"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/UpdateGroup", request_serializer=vmmigration.UpdateGroupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1318,7 +1409,7 @@ def delete_group( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_group" not in self._stubs: - self._stubs["delete_group"] = self.grpc_channel.unary_unary( + self._stubs["delete_group"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/DeleteGroup", request_serializer=vmmigration.DeleteGroupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1346,7 +1437,7 @@ def add_group_migration( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_group_migration" not in self._stubs: - self._stubs["add_group_migration"] = self.grpc_channel.unary_unary( + self._stubs["add_group_migration"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/AddGroupMigration", request_serializer=vmmigration.AddGroupMigrationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1374,7 +1465,7 @@ def remove_group_migration( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_group_migration" not in self._stubs: - self._stubs["remove_group_migration"] = self.grpc_channel.unary_unary( + self._stubs["remove_group_migration"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/RemoveGroupMigration", request_serializer=vmmigration.RemoveGroupMigrationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1406,7 +1497,7 @@ def list_target_projects( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_target_projects" not in self._stubs: - self._stubs["list_target_projects"] = self.grpc_channel.unary_unary( + self._stubs["list_target_projects"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListTargetProjects", request_serializer=vmmigration.ListTargetProjectsRequest.serialize, response_deserializer=vmmigration.ListTargetProjectsResponse.deserialize, @@ -1437,7 +1528,7 @@ def get_target_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_target_project" not in self._stubs: - self._stubs["get_target_project"] = self.grpc_channel.unary_unary( + self._stubs["get_target_project"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetTargetProject", request_serializer=vmmigration.GetTargetProjectRequest.serialize, response_deserializer=vmmigration.TargetProject.deserialize, @@ -1468,7 +1559,7 @@ def create_target_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_target_project" not in self._stubs: - self._stubs["create_target_project"] = self.grpc_channel.unary_unary( + self._stubs["create_target_project"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateTargetProject", request_serializer=vmmigration.CreateTargetProjectRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1499,7 +1590,7 @@ def update_target_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_target_project" not in self._stubs: - self._stubs["update_target_project"] = self.grpc_channel.unary_unary( + self._stubs["update_target_project"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/UpdateTargetProject", request_serializer=vmmigration.UpdateTargetProjectRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1530,7 +1621,7 @@ def delete_target_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_target_project" not in self._stubs: - self._stubs["delete_target_project"] = self.grpc_channel.unary_unary( + self._stubs["delete_target_project"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/DeleteTargetProject", request_serializer=vmmigration.DeleteTargetProjectRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1559,7 +1650,7 @@ def list_replication_cycles( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_replication_cycles" not in self._stubs: - self._stubs["list_replication_cycles"] = self.grpc_channel.unary_unary( + self._stubs["list_replication_cycles"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListReplicationCycles", request_serializer=vmmigration.ListReplicationCyclesRequest.serialize, response_deserializer=vmmigration.ListReplicationCyclesResponse.deserialize, @@ -1588,7 +1679,7 @@ def get_replication_cycle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_replication_cycle" not in self._stubs: - self._stubs["get_replication_cycle"] = self.grpc_channel.unary_unary( + self._stubs["get_replication_cycle"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetReplicationCycle", request_serializer=vmmigration.GetReplicationCycleRequest.serialize, response_deserializer=vmmigration.ReplicationCycle.deserialize, @@ -1866,7 +1957,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: @@ -1882,7 +1973,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, @@ -1899,7 +1990,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, @@ -1916,7 +2007,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, @@ -1935,7 +2026,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, @@ -1954,7 +2045,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, @@ -1971,7 +2062,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-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/transports/rest.py b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/transports/rest.py index 6e410a960e70..2c6f5d8aa46f 100644 --- a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/transports/rest.py +++ b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/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, @@ -441,8 +449,10 @@ def post_upgrade_appliance(self, response): def pre_add_group_migration( self, request: vmmigration.AddGroupMigrationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.AddGroupMigrationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.AddGroupMigrationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for add_group_migration Override in a subclass to manipulate the request or metadata @@ -464,8 +474,10 @@ def post_add_group_migration( def pre_cancel_clone_job( self, request: vmmigration.CancelCloneJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.CancelCloneJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.CancelCloneJobRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_clone_job Override in a subclass to manipulate the request or metadata @@ -487,8 +499,10 @@ def post_cancel_clone_job( def pre_cancel_cutover_job( self, request: vmmigration.CancelCutoverJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.CancelCutoverJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.CancelCutoverJobRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_cutover_job Override in a subclass to manipulate the request or metadata @@ -510,8 +524,10 @@ def post_cancel_cutover_job( def pre_create_clone_job( self, request: vmmigration.CreateCloneJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.CreateCloneJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.CreateCloneJobRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_clone_job Override in a subclass to manipulate the request or metadata @@ -533,8 +549,10 @@ def post_create_clone_job( def pre_create_cutover_job( self, request: vmmigration.CreateCutoverJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.CreateCutoverJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.CreateCutoverJobRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_cutover_job Override in a subclass to manipulate the request or metadata @@ -556,8 +574,11 @@ def post_create_cutover_job( def pre_create_datacenter_connector( self, request: vmmigration.CreateDatacenterConnectorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.CreateDatacenterConnectorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.CreateDatacenterConnectorRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_datacenter_connector Override in a subclass to manipulate the request or metadata @@ -579,8 +600,8 @@ def post_create_datacenter_connector( def pre_create_group( self, request: vmmigration.CreateGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.CreateGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vmmigration.CreateGroupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_group Override in a subclass to manipulate the request or metadata @@ -602,8 +623,10 @@ def post_create_group( def pre_create_migrating_vm( self, request: vmmigration.CreateMigratingVmRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.CreateMigratingVmRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.CreateMigratingVmRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_migrating_vm Override in a subclass to manipulate the request or metadata @@ -625,8 +648,10 @@ def post_create_migrating_vm( def pre_create_source( self, request: vmmigration.CreateSourceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.CreateSourceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.CreateSourceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_source Override in a subclass to manipulate the request or metadata @@ -648,8 +673,10 @@ def post_create_source( def pre_create_target_project( self, request: vmmigration.CreateTargetProjectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.CreateTargetProjectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.CreateTargetProjectRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_target_project Override in a subclass to manipulate the request or metadata @@ -671,8 +698,11 @@ def post_create_target_project( def pre_create_utilization_report( self, request: vmmigration.CreateUtilizationReportRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.CreateUtilizationReportRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.CreateUtilizationReportRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_utilization_report Override in a subclass to manipulate the request or metadata @@ -694,8 +724,11 @@ def post_create_utilization_report( def pre_delete_datacenter_connector( self, request: vmmigration.DeleteDatacenterConnectorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.DeleteDatacenterConnectorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.DeleteDatacenterConnectorRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_datacenter_connector Override in a subclass to manipulate the request or metadata @@ -717,8 +750,8 @@ def post_delete_datacenter_connector( def pre_delete_group( self, request: vmmigration.DeleteGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.DeleteGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vmmigration.DeleteGroupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_group Override in a subclass to manipulate the request or metadata @@ -740,8 +773,10 @@ def post_delete_group( def pre_delete_migrating_vm( self, request: vmmigration.DeleteMigratingVmRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.DeleteMigratingVmRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.DeleteMigratingVmRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_migrating_vm Override in a subclass to manipulate the request or metadata @@ -763,8 +798,10 @@ def post_delete_migrating_vm( def pre_delete_source( self, request: vmmigration.DeleteSourceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.DeleteSourceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.DeleteSourceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_source Override in a subclass to manipulate the request or metadata @@ -786,8 +823,10 @@ def post_delete_source( def pre_delete_target_project( self, request: vmmigration.DeleteTargetProjectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.DeleteTargetProjectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.DeleteTargetProjectRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_target_project Override in a subclass to manipulate the request or metadata @@ -809,8 +848,11 @@ def post_delete_target_project( def pre_delete_utilization_report( self, request: vmmigration.DeleteUtilizationReportRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.DeleteUtilizationReportRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.DeleteUtilizationReportRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_utilization_report Override in a subclass to manipulate the request or metadata @@ -832,8 +874,10 @@ def post_delete_utilization_report( def pre_fetch_inventory( self, request: vmmigration.FetchInventoryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.FetchInventoryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.FetchInventoryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for fetch_inventory Override in a subclass to manipulate the request or metadata @@ -855,8 +899,10 @@ def post_fetch_inventory( def pre_finalize_migration( self, request: vmmigration.FinalizeMigrationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.FinalizeMigrationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.FinalizeMigrationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for finalize_migration Override in a subclass to manipulate the request or metadata @@ -878,8 +924,8 @@ def post_finalize_migration( def pre_get_clone_job( self, request: vmmigration.GetCloneJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.GetCloneJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vmmigration.GetCloneJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_clone_job Override in a subclass to manipulate the request or metadata @@ -901,8 +947,10 @@ def post_get_clone_job( def pre_get_cutover_job( self, request: vmmigration.GetCutoverJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.GetCutoverJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.GetCutoverJobRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_cutover_job Override in a subclass to manipulate the request or metadata @@ -924,8 +972,11 @@ def post_get_cutover_job( def pre_get_datacenter_connector( self, request: vmmigration.GetDatacenterConnectorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.GetDatacenterConnectorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.GetDatacenterConnectorRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_datacenter_connector Override in a subclass to manipulate the request or metadata @@ -945,8 +996,10 @@ def post_get_datacenter_connector( return response def pre_get_group( - self, request: vmmigration.GetGroupRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[vmmigration.GetGroupRequest, Sequence[Tuple[str, str]]]: + self, + request: vmmigration.GetGroupRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vmmigration.GetGroupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_group Override in a subclass to manipulate the request or metadata @@ -966,8 +1019,10 @@ def post_get_group(self, response: vmmigration.Group) -> vmmigration.Group: def pre_get_migrating_vm( self, request: vmmigration.GetMigratingVmRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.GetMigratingVmRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.GetMigratingVmRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_migrating_vm Override in a subclass to manipulate the request or metadata @@ -989,8 +1044,10 @@ def post_get_migrating_vm( def pre_get_replication_cycle( self, request: vmmigration.GetReplicationCycleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.GetReplicationCycleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.GetReplicationCycleRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_replication_cycle Override in a subclass to manipulate the request or metadata @@ -1010,8 +1067,10 @@ def post_get_replication_cycle( return response def pre_get_source( - self, request: vmmigration.GetSourceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[vmmigration.GetSourceRequest, Sequence[Tuple[str, str]]]: + self, + request: vmmigration.GetSourceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vmmigration.GetSourceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_source Override in a subclass to manipulate the request or metadata @@ -1031,8 +1090,10 @@ def post_get_source(self, response: vmmigration.Source) -> vmmigration.Source: def pre_get_target_project( self, request: vmmigration.GetTargetProjectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.GetTargetProjectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.GetTargetProjectRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_target_project Override in a subclass to manipulate the request or metadata @@ -1054,8 +1115,10 @@ def post_get_target_project( def pre_get_utilization_report( self, request: vmmigration.GetUtilizationReportRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.GetUtilizationReportRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.GetUtilizationReportRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_utilization_report Override in a subclass to manipulate the request or metadata @@ -1077,8 +1140,10 @@ def post_get_utilization_report( def pre_list_clone_jobs( self, request: vmmigration.ListCloneJobsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.ListCloneJobsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.ListCloneJobsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_clone_jobs Override in a subclass to manipulate the request or metadata @@ -1100,8 +1165,10 @@ def post_list_clone_jobs( def pre_list_cutover_jobs( self, request: vmmigration.ListCutoverJobsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.ListCutoverJobsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.ListCutoverJobsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_cutover_jobs Override in a subclass to manipulate the request or metadata @@ -1123,8 +1190,11 @@ def post_list_cutover_jobs( def pre_list_datacenter_connectors( self, request: vmmigration.ListDatacenterConnectorsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.ListDatacenterConnectorsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.ListDatacenterConnectorsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_datacenter_connectors Override in a subclass to manipulate the request or metadata @@ -1146,8 +1216,8 @@ def post_list_datacenter_connectors( def pre_list_groups( self, request: vmmigration.ListGroupsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.ListGroupsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vmmigration.ListGroupsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_groups Override in a subclass to manipulate the request or metadata @@ -1169,8 +1239,10 @@ def post_list_groups( def pre_list_migrating_vms( self, request: vmmigration.ListMigratingVmsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.ListMigratingVmsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.ListMigratingVmsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_migrating_vms Override in a subclass to manipulate the request or metadata @@ -1192,8 +1264,11 @@ def post_list_migrating_vms( def pre_list_replication_cycles( self, request: vmmigration.ListReplicationCyclesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.ListReplicationCyclesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.ListReplicationCyclesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_replication_cycles Override in a subclass to manipulate the request or metadata @@ -1215,8 +1290,8 @@ def post_list_replication_cycles( def pre_list_sources( self, request: vmmigration.ListSourcesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.ListSourcesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vmmigration.ListSourcesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_sources Override in a subclass to manipulate the request or metadata @@ -1238,8 +1313,10 @@ def post_list_sources( def pre_list_target_projects( self, request: vmmigration.ListTargetProjectsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.ListTargetProjectsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.ListTargetProjectsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_target_projects Override in a subclass to manipulate the request or metadata @@ -1261,8 +1338,11 @@ def post_list_target_projects( def pre_list_utilization_reports( self, request: vmmigration.ListUtilizationReportsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.ListUtilizationReportsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.ListUtilizationReportsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_utilization_reports Override in a subclass to manipulate the request or metadata @@ -1284,8 +1364,10 @@ def post_list_utilization_reports( def pre_pause_migration( self, request: vmmigration.PauseMigrationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.PauseMigrationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.PauseMigrationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for pause_migration Override in a subclass to manipulate the request or metadata @@ -1307,8 +1389,10 @@ def post_pause_migration( def pre_remove_group_migration( self, request: vmmigration.RemoveGroupMigrationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.RemoveGroupMigrationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.RemoveGroupMigrationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for remove_group_migration Override in a subclass to manipulate the request or metadata @@ -1330,8 +1414,10 @@ def post_remove_group_migration( def pre_resume_migration( self, request: vmmigration.ResumeMigrationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.ResumeMigrationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.ResumeMigrationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for resume_migration Override in a subclass to manipulate the request or metadata @@ -1353,8 +1439,10 @@ def post_resume_migration( def pre_start_migration( self, request: vmmigration.StartMigrationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.StartMigrationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.StartMigrationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for start_migration Override in a subclass to manipulate the request or metadata @@ -1376,8 +1464,8 @@ def post_start_migration( def pre_update_group( self, request: vmmigration.UpdateGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.UpdateGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vmmigration.UpdateGroupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_group Override in a subclass to manipulate the request or metadata @@ -1399,8 +1487,10 @@ def post_update_group( def pre_update_migrating_vm( self, request: vmmigration.UpdateMigratingVmRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.UpdateMigratingVmRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.UpdateMigratingVmRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_migrating_vm Override in a subclass to manipulate the request or metadata @@ -1422,8 +1512,10 @@ def post_update_migrating_vm( def pre_update_source( self, request: vmmigration.UpdateSourceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.UpdateSourceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.UpdateSourceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_source Override in a subclass to manipulate the request or metadata @@ -1445,8 +1537,10 @@ def post_update_source( def pre_update_target_project( self, request: vmmigration.UpdateTargetProjectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.UpdateTargetProjectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.UpdateTargetProjectRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_target_project Override in a subclass to manipulate the request or metadata @@ -1468,8 +1562,10 @@ def post_update_target_project( def pre_upgrade_appliance( self, request: vmmigration.UpgradeApplianceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.UpgradeApplianceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.UpgradeApplianceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for upgrade_appliance Override in a subclass to manipulate the request or metadata @@ -1491,8 +1587,10 @@ def post_upgrade_appliance( 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 @@ -1514,8 +1612,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 @@ -1537,8 +1637,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 @@ -1558,8 +1660,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 @@ -1579,8 +1683,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 @@ -1602,8 +1708,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 @@ -1798,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]]] = (), ) -> operations_pb2.Operation: r"""Call the add group migration method over HTTP. @@ -1809,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: ~.operations_pb2.Operation: @@ -1823,6 +1933,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseAddGroupMigration._get_http_options() ) + request, metadata = self._interceptor.pre_add_group_migration( request, metadata ) @@ -1839,6 +1950,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.AddGroupMigration", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "AddGroupMigration", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._AddGroupMigration._get_response( self._host, @@ -1858,7 +1996,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_group_migration(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.add_group_migration", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "AddGroupMigration", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CancelCloneJob( @@ -1896,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 cancel clone job method over HTTP. @@ -1907,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: ~.operations_pb2.Operation: @@ -1921,6 +2083,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseCancelCloneJob._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_clone_job( request, metadata ) @@ -1937,6 +2100,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.CancelCloneJob", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CancelCloneJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._CancelCloneJob._get_response( self._host, @@ -1956,7 +2146,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_clone_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.vmmigration_v1.VmMigrationClient.cancel_clone_job", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CancelCloneJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CancelCutoverJob( @@ -1994,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.Operation: r"""Call the cancel cutover job method over HTTP. @@ -2005,8 +2217,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2019,6 +2233,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseCancelCutoverJob._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_cutover_job( request, metadata ) @@ -2035,6 +2250,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.CancelCutoverJob", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CancelCutoverJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._CancelCutoverJob._get_response( self._host, @@ -2054,7 +2296,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_cutover_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.vmmigration_v1.VmMigrationClient.cancel_cutover_job", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CancelCutoverJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCloneJob( @@ -2092,7 +2356,7 @@ 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 clone job method over HTTP. @@ -2103,8 +2367,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2117,6 +2383,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseCreateCloneJob._get_http_options() ) + request, metadata = self._interceptor.pre_create_clone_job( request, metadata ) @@ -2133,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.CreateCloneJob", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateCloneJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._CreateCloneJob._get_response( self._host, @@ -2152,7 +2446,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_clone_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.vmmigration_v1.VmMigrationClient.create_clone_job", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateCloneJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCutoverJob( @@ -2190,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create cutover job method over HTTP. @@ -2201,8 +2517,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2215,6 +2533,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseCreateCutoverJob._get_http_options() ) + request, metadata = self._interceptor.pre_create_cutover_job( request, metadata ) @@ -2231,6 +2550,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.CreateCutoverJob", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateCutoverJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._CreateCutoverJob._get_response( self._host, @@ -2250,7 +2596,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_cutover_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.vmmigration_v1.VmMigrationClient.create_cutover_job", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateCutoverJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateDatacenterConnector( @@ -2289,7 +2657,7 @@ 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 datacenter connector method over HTTP. @@ -2301,8 +2669,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2315,6 +2685,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseCreateDatacenterConnector._get_http_options() ) + request, metadata = self._interceptor.pre_create_datacenter_connector( request, metadata ) @@ -2331,6 +2702,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.CreateDatacenterConnector", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateDatacenterConnector", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmMigrationRestTransport._CreateDatacenterConnector._get_response( @@ -2352,7 +2750,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_datacenter_connector(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.create_datacenter_connector", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateDatacenterConnector", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateGroup( @@ -2390,7 +2810,7 @@ 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 group method over HTTP. @@ -2401,8 +2821,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2415,6 +2837,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseCreateGroup._get_http_options() ) + request, metadata = self._interceptor.pre_create_group(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseCreateGroup._get_transcoded_request( @@ -2435,6 +2858,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.CreateGroup", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateGroup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._CreateGroup._get_response( self._host, @@ -2454,7 +2904,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_group(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.create_group", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateGroup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateMigratingVm( @@ -2492,7 +2964,7 @@ 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 migrating vm method over HTTP. @@ -2503,8 +2975,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2517,6 +2991,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseCreateMigratingVm._get_http_options() ) + request, metadata = self._interceptor.pre_create_migrating_vm( request, metadata ) @@ -2533,6 +3008,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.CreateMigratingVm", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateMigratingVm", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._CreateMigratingVm._get_response( self._host, @@ -2552,7 +3054,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_migrating_vm(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.create_migrating_vm", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateMigratingVm", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSource( @@ -2590,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create source method over HTTP. @@ -2601,8 +3125,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2615,6 +3141,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseCreateSource._get_http_options() ) + request, metadata = self._interceptor.pre_create_source(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseCreateSource._get_transcoded_request( @@ -2635,6 +3162,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.CreateSource", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateSource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._CreateSource._get_response( self._host, @@ -2654,7 +3208,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_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.cloud.vmmigration_v1.VmMigrationClient.create_source", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateSource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateTargetProject( @@ -2692,7 +3268,7 @@ 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 target project method over HTTP. @@ -2703,8 +3279,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2717,6 +3295,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseCreateTargetProject._get_http_options() ) + request, metadata = self._interceptor.pre_create_target_project( request, metadata ) @@ -2733,6 +3312,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.CreateTargetProject", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateTargetProject", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._CreateTargetProject._get_response( self._host, @@ -2752,7 +3358,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_target_project(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.create_target_project", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateTargetProject", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateUtilizationReport( @@ -2790,7 +3418,7 @@ 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 utilization report method over HTTP. @@ -2801,8 +3429,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2815,6 +3445,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseCreateUtilizationReport._get_http_options() ) + request, metadata = self._interceptor.pre_create_utilization_report( request, metadata ) @@ -2831,6 +3462,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.CreateUtilizationReport", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateUtilizationReport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._CreateUtilizationReport._get_response( self._host, @@ -2850,7 +3508,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_utilization_report(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.create_utilization_report", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateUtilizationReport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteDatacenterConnector( @@ -2888,7 +3568,7 @@ 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 datacenter connector method over HTTP. @@ -2900,8 +3580,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2914,6 +3596,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseDeleteDatacenterConnector._get_http_options() ) + request, metadata = self._interceptor.pre_delete_datacenter_connector( request, metadata ) @@ -2926,6 +3609,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.DeleteDatacenterConnector", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteDatacenterConnector", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmMigrationRestTransport._DeleteDatacenterConnector._get_response( @@ -2946,7 +3656,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_datacenter_connector(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.delete_datacenter_connector", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteDatacenterConnector", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteGroup( @@ -2983,7 +3715,7 @@ 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 group method over HTTP. @@ -2994,8 +3726,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3008,6 +3742,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseDeleteGroup._get_http_options() ) + request, metadata = self._interceptor.pre_delete_group(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseDeleteGroup._get_transcoded_request( @@ -3022,6 +3757,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.DeleteGroup", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteGroup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._DeleteGroup._get_response( self._host, @@ -3040,7 +3802,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_group(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.delete_group", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteGroup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteMigratingVm( @@ -3077,7 +3861,7 @@ 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 migrating vm method over HTTP. @@ -3088,8 +3872,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3102,6 +3888,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseDeleteMigratingVm._get_http_options() ) + request, metadata = self._interceptor.pre_delete_migrating_vm( request, metadata ) @@ -3114,6 +3901,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.DeleteMigratingVm", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteMigratingVm", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._DeleteMigratingVm._get_response( self._host, @@ -3132,7 +3946,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_migrating_vm(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.delete_migrating_vm", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteMigratingVm", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteSource( @@ -3169,7 +4005,7 @@ 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 source method over HTTP. @@ -3180,8 +4016,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3194,6 +4032,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseDeleteSource._get_http_options() ) + request, metadata = self._interceptor.pre_delete_source(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseDeleteSource._get_transcoded_request( @@ -3208,6 +4047,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.DeleteSource", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteSource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._DeleteSource._get_response( self._host, @@ -3226,7 +4092,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_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.cloud.vmmigration_v1.VmMigrationClient.delete_source", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteSource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteTargetProject( @@ -3263,7 +4151,7 @@ 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 target project method over HTTP. @@ -3274,8 +4162,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3288,6 +4178,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseDeleteTargetProject._get_http_options() ) + request, metadata = self._interceptor.pre_delete_target_project( request, metadata ) @@ -3300,6 +4191,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.DeleteTargetProject", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteTargetProject", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._DeleteTargetProject._get_response( self._host, @@ -3318,7 +4236,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_target_project(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.delete_target_project", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteTargetProject", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteUtilizationReport( @@ -3355,7 +4295,7 @@ 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 utilization report method over HTTP. @@ -3366,8 +4306,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3380,6 +4322,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseDeleteUtilizationReport._get_http_options() ) + request, metadata = self._interceptor.pre_delete_utilization_report( request, metadata ) @@ -3392,6 +4335,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.DeleteUtilizationReport", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteUtilizationReport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._DeleteUtilizationReport._get_response( self._host, @@ -3410,7 +4380,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_utilization_report(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.delete_utilization_report", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteUtilizationReport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _FetchInventory( @@ -3447,7 +4439,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.FetchInventoryResponse: r"""Call the fetch inventory method over HTTP. @@ -3458,8 +4450,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmmigration.FetchInventoryResponse: @@ -3471,6 +4465,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseFetchInventory._get_http_options() ) + request, metadata = self._interceptor.pre_fetch_inventory(request, metadata) transcoded_request = _BaseVmMigrationRestTransport._BaseFetchInventory._get_transcoded_request( http_options, request @@ -3481,6 +4476,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.FetchInventory", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "FetchInventory", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._FetchInventory._get_response( self._host, @@ -3501,7 +4523,31 @@ def __call__( pb_resp = vmmigration.FetchInventoryResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_fetch_inventory(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.FetchInventoryResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.fetch_inventory", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "FetchInventory", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _FinalizeMigration( @@ -3539,7 +4585,7 @@ 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 finalize migration method over HTTP. @@ -3550,8 +4596,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3564,6 +4612,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseFinalizeMigration._get_http_options() ) + request, metadata = self._interceptor.pre_finalize_migration( request, metadata ) @@ -3580,6 +4629,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.FinalizeMigration", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "FinalizeMigration", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._FinalizeMigration._get_response( self._host, @@ -3599,7 +4675,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_finalize_migration(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.finalize_migration", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "FinalizeMigration", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCloneJob( @@ -3636,7 +4734,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.CloneJob: r"""Call the get clone job method over HTTP. @@ -3647,8 +4745,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmmigration.CloneJob: @@ -3671,6 +4771,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseGetCloneJob._get_http_options() ) + request, metadata = self._interceptor.pre_get_clone_job(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseGetCloneJob._get_transcoded_request( @@ -3685,6 +4786,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.GetCloneJob", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetCloneJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._GetCloneJob._get_response( self._host, @@ -3705,7 +4833,29 @@ def __call__( pb_resp = vmmigration.CloneJob.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_clone_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.CloneJob.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.get_clone_job", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetCloneJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCutoverJob( @@ -3742,7 +4892,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.CutoverJob: r"""Call the get cutover job method over HTTP. @@ -3753,8 +4903,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmmigration.CutoverJob: @@ -3770,6 +4922,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseGetCutoverJob._get_http_options() ) + request, metadata = self._interceptor.pre_get_cutover_job(request, metadata) transcoded_request = _BaseVmMigrationRestTransport._BaseGetCutoverJob._get_transcoded_request( http_options, request @@ -3782,6 +4935,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.GetCutoverJob", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetCutoverJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._GetCutoverJob._get_response( self._host, @@ -3802,7 +4982,29 @@ def __call__( pb_resp = vmmigration.CutoverJob.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_cutover_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.CutoverJob.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.get_cutover_job", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetCutoverJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDatacenterConnector( @@ -3839,7 +5041,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.DatacenterConnector: r"""Call the get datacenter connector method over HTTP. @@ -3850,8 +5052,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmmigration.DatacenterConnector: @@ -3868,6 +5072,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseGetDatacenterConnector._get_http_options() ) + request, metadata = self._interceptor.pre_get_datacenter_connector( request, metadata ) @@ -3880,6 +5085,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.GetDatacenterConnector", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetDatacenterConnector", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._GetDatacenterConnector._get_response( self._host, @@ -3900,7 +5132,29 @@ def __call__( pb_resp = vmmigration.DatacenterConnector.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_datacenter_connector(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.DatacenterConnector.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.get_datacenter_connector", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetDatacenterConnector", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetGroup(_BaseVmMigrationRestTransport._BaseGetGroup, VmMigrationRestStub): @@ -3935,7 +5189,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.Group: r"""Call the get group method over HTTP. @@ -3946,8 +5200,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmmigration.Group: @@ -3960,6 +5216,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseGetGroup._get_http_options() ) + request, metadata = self._interceptor.pre_get_group(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseGetGroup._get_transcoded_request( @@ -3974,6 +5231,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.GetGroup", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetGroup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._GetGroup._get_response( self._host, @@ -3994,7 +5278,29 @@ def __call__( pb_resp = vmmigration.Group.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_group(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.Group.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.get_group", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetGroup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetMigratingVm( @@ -4031,7 +5337,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.MigratingVm: r"""Call the get migrating vm method over HTTP. @@ -4042,8 +5348,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmmigration.MigratingVm: @@ -4056,6 +5364,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseGetMigratingVm._get_http_options() ) + request, metadata = self._interceptor.pre_get_migrating_vm( request, metadata ) @@ -4068,6 +5377,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.GetMigratingVm", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetMigratingVm", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._GetMigratingVm._get_response( self._host, @@ -4088,7 +5424,29 @@ def __call__( pb_resp = vmmigration.MigratingVm.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_migrating_vm(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.MigratingVm.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.get_migrating_vm", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetMigratingVm", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetReplicationCycle( @@ -4125,7 +5483,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.ReplicationCycle: r"""Call the get replication cycle method over HTTP. @@ -4136,8 +5494,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmmigration.ReplicationCycle: @@ -4150,6 +5510,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseGetReplicationCycle._get_http_options() ) + request, metadata = self._interceptor.pre_get_replication_cycle( request, metadata ) @@ -4162,6 +5523,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.GetReplicationCycle", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetReplicationCycle", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._GetReplicationCycle._get_response( self._host, @@ -4182,7 +5570,29 @@ def __call__( pb_resp = vmmigration.ReplicationCycle.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_replication_cycle(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.ReplicationCycle.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.get_replication_cycle", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetReplicationCycle", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSource(_BaseVmMigrationRestTransport._BaseGetSource, VmMigrationRestStub): @@ -4217,7 +5627,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.Source: r"""Call the get source method over HTTP. @@ -4228,8 +5638,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmmigration.Source: @@ -4243,6 +5655,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseGetSource._get_http_options() ) + request, metadata = self._interceptor.pre_get_source(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseGetSource._get_transcoded_request( @@ -4257,6 +5670,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.GetSource", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetSource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._GetSource._get_response( self._host, @@ -4277,7 +5717,29 @@ def __call__( pb_resp = vmmigration.Source.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_source(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.Source.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.get_source", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetSource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTargetProject( @@ -4314,7 +5776,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.TargetProject: r"""Call the get target project method over HTTP. @@ -4325,8 +5787,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmmigration.TargetProject: @@ -4339,6 +5803,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseGetTargetProject._get_http_options() ) + request, metadata = self._interceptor.pre_get_target_project( request, metadata ) @@ -4351,6 +5816,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.GetTargetProject", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetTargetProject", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._GetTargetProject._get_response( self._host, @@ -4371,7 +5863,29 @@ def __call__( pb_resp = vmmigration.TargetProject.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_target_project(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.TargetProject.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.get_target_project", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetTargetProject", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetUtilizationReport( @@ -4408,7 +5922,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.UtilizationReport: r"""Call the get utilization report method over HTTP. @@ -4419,8 +5933,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmmigration.UtilizationReport: @@ -4433,6 +5949,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseGetUtilizationReport._get_http_options() ) + request, metadata = self._interceptor.pre_get_utilization_report( request, metadata ) @@ -4445,6 +5962,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.GetUtilizationReport", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetUtilizationReport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._GetUtilizationReport._get_response( self._host, @@ -4465,7 +6009,29 @@ def __call__( pb_resp = vmmigration.UtilizationReport.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_utilization_report(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.UtilizationReport.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.get_utilization_report", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetUtilizationReport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCloneJobs( @@ -4502,7 +6068,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.ListCloneJobsResponse: r"""Call the list clone jobs method over HTTP. @@ -4513,8 +6079,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmmigration.ListCloneJobsResponse: @@ -4526,6 +6094,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseListCloneJobs._get_http_options() ) + request, metadata = self._interceptor.pre_list_clone_jobs(request, metadata) transcoded_request = _BaseVmMigrationRestTransport._BaseListCloneJobs._get_transcoded_request( http_options, request @@ -4538,6 +6107,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.ListCloneJobs", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListCloneJobs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._ListCloneJobs._get_response( self._host, @@ -4558,7 +6154,31 @@ def __call__( pb_resp = vmmigration.ListCloneJobsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_clone_jobs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.ListCloneJobsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.list_clone_jobs", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListCloneJobs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCutoverJobs( @@ -4595,7 +6215,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.ListCutoverJobsResponse: r"""Call the list cutover jobs method over HTTP. @@ -4606,8 +6226,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmmigration.ListCutoverJobsResponse: @@ -4619,6 +6241,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseListCutoverJobs._get_http_options() ) + request, metadata = self._interceptor.pre_list_cutover_jobs( request, metadata ) @@ -4631,6 +6254,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.ListCutoverJobs", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListCutoverJobs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._ListCutoverJobs._get_response( self._host, @@ -4651,7 +6301,31 @@ def __call__( pb_resp = vmmigration.ListCutoverJobsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_cutover_jobs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.ListCutoverJobsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.list_cutover_jobs", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListCutoverJobs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDatacenterConnectors( @@ -4688,7 +6362,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.ListDatacenterConnectorsResponse: r"""Call the list datacenter connectors method over HTTP. @@ -4700,8 +6374,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmmigration.ListDatacenterConnectorsResponse: @@ -4713,6 +6389,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseListDatacenterConnectors._get_http_options() ) + request, metadata = self._interceptor.pre_list_datacenter_connectors( request, metadata ) @@ -4725,6 +6402,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.ListDatacenterConnectors", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListDatacenterConnectors", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._ListDatacenterConnectors._get_response( self._host, @@ -4745,7 +6449,31 @@ def __call__( pb_resp = vmmigration.ListDatacenterConnectorsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_datacenter_connectors(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmmigration.ListDatacenterConnectorsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.list_datacenter_connectors", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListDatacenterConnectors", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListGroups( @@ -4782,7 +6510,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.ListGroupsResponse: r"""Call the list groups method over HTTP. @@ -4793,8 +6521,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmmigration.ListGroupsResponse: @@ -4806,6 +6536,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseListGroups._get_http_options() ) + request, metadata = self._interceptor.pre_list_groups(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseListGroups._get_transcoded_request( @@ -4820,6 +6551,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.ListGroups", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListGroups", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._ListGroups._get_response( self._host, @@ -4840,7 +6598,29 @@ def __call__( pb_resp = vmmigration.ListGroupsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_groups(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.ListGroupsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.list_groups", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListGroups", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListMigratingVms( @@ -4877,7 +6657,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.ListMigratingVmsResponse: r"""Call the list migrating vms method over HTTP. @@ -4888,8 +6668,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmmigration.ListMigratingVmsResponse: @@ -4901,6 +6683,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseListMigratingVms._get_http_options() ) + request, metadata = self._interceptor.pre_list_migrating_vms( request, metadata ) @@ -4913,6 +6696,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.ListMigratingVms", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListMigratingVms", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._ListMigratingVms._get_response( self._host, @@ -4933,7 +6743,31 @@ def __call__( pb_resp = vmmigration.ListMigratingVmsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_migrating_vms(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.ListMigratingVmsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.list_migrating_vms", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListMigratingVms", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListReplicationCycles( @@ -4970,7 +6804,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.ListReplicationCyclesResponse: r"""Call the list replication cycles method over HTTP. @@ -4981,8 +6815,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmmigration.ListReplicationCyclesResponse: @@ -4994,6 +6830,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseListReplicationCycles._get_http_options() ) + request, metadata = self._interceptor.pre_list_replication_cycles( request, metadata ) @@ -5006,6 +6843,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.ListReplicationCycles", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListReplicationCycles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._ListReplicationCycles._get_response( self._host, @@ -5026,7 +6890,31 @@ def __call__( pb_resp = vmmigration.ListReplicationCyclesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_replication_cycles(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmmigration.ListReplicationCyclesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.list_replication_cycles", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListReplicationCycles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSources( @@ -5063,7 +6951,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.ListSourcesResponse: r"""Call the list sources method over HTTP. @@ -5074,8 +6962,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmmigration.ListSourcesResponse: @@ -5087,6 +6977,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseListSources._get_http_options() ) + request, metadata = self._interceptor.pre_list_sources(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseListSources._get_transcoded_request( @@ -5101,6 +6992,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.ListSources", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListSources", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._ListSources._get_response( self._host, @@ -5121,7 +7039,29 @@ def __call__( pb_resp = vmmigration.ListSourcesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_sources(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.ListSourcesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.list_sources", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListSources", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTargetProjects( @@ -5158,7 +7098,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.ListTargetProjectsResponse: r"""Call the list target projects method over HTTP. @@ -5169,8 +7109,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmmigration.ListTargetProjectsResponse: @@ -5182,6 +7124,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseListTargetProjects._get_http_options() ) + request, metadata = self._interceptor.pre_list_target_projects( request, metadata ) @@ -5194,6 +7137,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.ListTargetProjects", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListTargetProjects", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._ListTargetProjects._get_response( self._host, @@ -5214,7 +7184,31 @@ def __call__( pb_resp = vmmigration.ListTargetProjectsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_target_projects(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.ListTargetProjectsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.list_target_projects", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListTargetProjects", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListUtilizationReports( @@ -5251,7 +7245,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.ListUtilizationReportsResponse: r"""Call the list utilization reports method over HTTP. @@ -5262,8 +7256,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmmigration.ListUtilizationReportsResponse: @@ -5275,6 +7271,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseListUtilizationReports._get_http_options() ) + request, metadata = self._interceptor.pre_list_utilization_reports( request, metadata ) @@ -5287,6 +7284,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.ListUtilizationReports", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListUtilizationReports", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._ListUtilizationReports._get_response( self._host, @@ -5307,7 +7331,31 @@ def __call__( pb_resp = vmmigration.ListUtilizationReportsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_utilization_reports(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmmigration.ListUtilizationReportsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.list_utilization_reports", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListUtilizationReports", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PauseMigration( @@ -5345,7 +7393,7 @@ 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 pause migration method over HTTP. @@ -5356,8 +7404,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -5370,6 +7420,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BasePauseMigration._get_http_options() ) + request, metadata = self._interceptor.pre_pause_migration(request, metadata) transcoded_request = _BaseVmMigrationRestTransport._BasePauseMigration._get_transcoded_request( http_options, request @@ -5384,6 +7435,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.PauseMigration", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "PauseMigration", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._PauseMigration._get_response( self._host, @@ -5403,7 +7481,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_pause_migration(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.pause_migration", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "PauseMigration", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveGroupMigration( @@ -5441,7 +7541,7 @@ 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 remove group migration method over HTTP. @@ -5452,8 +7552,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -5466,6 +7568,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseRemoveGroupMigration._get_http_options() ) + request, metadata = self._interceptor.pre_remove_group_migration( request, metadata ) @@ -5482,6 +7585,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.RemoveGroupMigration", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "RemoveGroupMigration", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._RemoveGroupMigration._get_response( self._host, @@ -5501,7 +7631,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_group_migration(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.remove_group_migration", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "RemoveGroupMigration", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ResumeMigration( @@ -5539,7 +7691,7 @@ 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 resume migration method over HTTP. @@ -5550,8 +7702,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -5564,6 +7718,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseResumeMigration._get_http_options() ) + request, metadata = self._interceptor.pre_resume_migration( request, metadata ) @@ -5580,6 +7735,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.ResumeMigration", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ResumeMigration", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._ResumeMigration._get_response( self._host, @@ -5599,7 +7781,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_resume_migration(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.resume_migration", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ResumeMigration", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StartMigration( @@ -5637,7 +7841,7 @@ 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 start migration method over HTTP. @@ -5648,8 +7852,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -5662,6 +7868,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseStartMigration._get_http_options() ) + request, metadata = self._interceptor.pre_start_migration(request, metadata) transcoded_request = _BaseVmMigrationRestTransport._BaseStartMigration._get_transcoded_request( http_options, request @@ -5676,6 +7883,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.StartMigration", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "StartMigration", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._StartMigration._get_response( self._host, @@ -5695,7 +7929,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_start_migration(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.start_migration", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "StartMigration", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateGroup( @@ -5733,7 +7989,7 @@ 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 group method over HTTP. @@ -5744,8 +8000,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -5758,6 +8016,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseUpdateGroup._get_http_options() ) + request, metadata = self._interceptor.pre_update_group(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseUpdateGroup._get_transcoded_request( @@ -5778,6 +8037,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.UpdateGroup", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "UpdateGroup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._UpdateGroup._get_response( self._host, @@ -5797,7 +8083,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_group(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.update_group", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "UpdateGroup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateMigratingVm( @@ -5835,7 +8143,7 @@ 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 migrating vm method over HTTP. @@ -5846,8 +8154,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -5860,6 +8170,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseUpdateMigratingVm._get_http_options() ) + request, metadata = self._interceptor.pre_update_migrating_vm( request, metadata ) @@ -5876,6 +8187,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.UpdateMigratingVm", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "UpdateMigratingVm", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._UpdateMigratingVm._get_response( self._host, @@ -5895,7 +8233,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_migrating_vm(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.update_migrating_vm", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "UpdateMigratingVm", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSource( @@ -5933,7 +8293,7 @@ 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 source method over HTTP. @@ -5944,8 +8304,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -5958,6 +8320,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseUpdateSource._get_http_options() ) + request, metadata = self._interceptor.pre_update_source(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseUpdateSource._get_transcoded_request( @@ -5978,6 +8341,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.UpdateSource", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "UpdateSource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._UpdateSource._get_response( self._host, @@ -5997,7 +8387,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_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.cloud.vmmigration_v1.VmMigrationClient.update_source", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "UpdateSource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateTargetProject( @@ -6035,7 +8447,7 @@ 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 target project method over HTTP. @@ -6046,8 +8458,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -6060,6 +8474,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseUpdateTargetProject._get_http_options() ) + request, metadata = self._interceptor.pre_update_target_project( request, metadata ) @@ -6076,6 +8491,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.UpdateTargetProject", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "UpdateTargetProject", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._UpdateTargetProject._get_response( self._host, @@ -6095,7 +8537,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_target_project(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.update_target_project", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "UpdateTargetProject", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpgradeAppliance( @@ -6133,7 +8597,7 @@ 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 upgrade appliance method over HTTP. @@ -6144,8 +8608,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -6158,6 +8624,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseUpgradeAppliance._get_http_options() ) + request, metadata = self._interceptor.pre_upgrade_appliance( request, metadata ) @@ -6174,6 +8641,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.UpgradeAppliance", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "UpgradeAppliance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._UpgradeAppliance._get_response( self._host, @@ -6193,7 +8687,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_upgrade_appliance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmmigration_v1.VmMigrationClient.upgrade_appliance", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "UpgradeAppliance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -6633,7 +9149,7 @@ 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. @@ -6643,8 +9159,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -6653,6 +9171,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseGetLocation._get_transcoded_request( @@ -6667,6 +9186,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.GetLocation", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._GetLocation._get_response( self._host, @@ -6686,6 +9232,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.vmmigration_v1.VmMigrationAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -6726,7 +9293,7 @@ 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. @@ -6736,8 +9303,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -6746,6 +9315,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseVmMigrationRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -6758,6 +9328,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.ListLocations", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._ListLocations._get_response( self._host, @@ -6777,6 +9374,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.vmmigration_v1.VmMigrationAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -6818,7 +9436,7 @@ 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. @@ -6828,13 +9446,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 = ( _BaseVmMigrationRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -6851,6 +9472,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.CancelOperation", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._CancelOperation._get_response( self._host, @@ -6907,7 +9555,7 @@ 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. @@ -6917,13 +9565,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 = ( _BaseVmMigrationRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -6936,6 +9587,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._DeleteOperation._get_response( self._host, @@ -6991,7 +9669,7 @@ 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. @@ -7001,8 +9679,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -7011,6 +9691,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseGetOperation._get_transcoded_request( @@ -7025,6 +9706,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.GetOperation", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._GetOperation._get_response( self._host, @@ -7044,6 +9752,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.vmmigration_v1.VmMigrationAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -7084,7 +9813,7 @@ 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. @@ -7094,8 +9823,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -7104,6 +9835,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseVmMigrationRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -7114,6 +9846,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmmigration_v1.VmMigrationClient.ListOperations", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._ListOperations._get_response( self._host, @@ -7133,6 +9892,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.vmmigration_v1.VmMigrationAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-vm-migration/samples/generated_samples/snippet_metadata_google.cloud.vmmigration.v1.json b/packages/google-cloud-vm-migration/samples/generated_samples/snippet_metadata_google.cloud.vmmigration.v1.json index 12b93cb65ff3..cfb6d660b704 100644 --- a/packages/google-cloud-vm-migration/samples/generated_samples/snippet_metadata_google.cloud.vmmigration.v1.json +++ b/packages/google-cloud-vm-migration/samples/generated_samples/snippet_metadata_google.cloud.vmmigration.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-vm-migration", - "version": "1.9.1" + "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.api_core.operation_async.AsyncOperation", @@ -449,7 +449,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.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", @@ -715,7 +715,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", @@ -892,7 +892,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -980,7 +980,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1069,7 +1069,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1157,7 +1157,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1246,7 +1246,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1334,7 +1334,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1423,7 +1423,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1511,7 +1511,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1600,7 +1600,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1688,7 +1688,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1777,7 +1777,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1865,7 +1865,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1946,7 +1946,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2026,7 +2026,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2107,7 +2107,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2187,7 +2187,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2268,7 +2268,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2348,7 +2348,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2429,7 +2429,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2509,7 +2509,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2590,7 +2590,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2670,7 +2670,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2751,7 +2751,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2831,7 +2831,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2912,7 +2912,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.FetchInventoryResponse", @@ -2992,7 +2992,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.FetchInventoryResponse", @@ -3073,7 +3073,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3153,7 +3153,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3234,7 +3234,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.CloneJob", @@ -3314,7 +3314,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.CloneJob", @@ -3395,7 +3395,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.CutoverJob", @@ -3475,7 +3475,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.CutoverJob", @@ -3556,7 +3556,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.DatacenterConnector", @@ -3636,7 +3636,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.DatacenterConnector", @@ -3717,7 +3717,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.Group", @@ -3797,7 +3797,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.Group", @@ -3878,7 +3878,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.MigratingVm", @@ -3958,7 +3958,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.MigratingVm", @@ -4039,7 +4039,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.ReplicationCycle", @@ -4119,7 +4119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.ReplicationCycle", @@ -4200,7 +4200,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.Source", @@ -4280,7 +4280,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.Source", @@ -4361,7 +4361,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.TargetProject", @@ -4441,7 +4441,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.TargetProject", @@ -4522,7 +4522,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.UtilizationReport", @@ -4602,7 +4602,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.UtilizationReport", @@ -4683,7 +4683,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListCloneJobsAsyncPager", @@ -4763,7 +4763,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListCloneJobsPager", @@ -4844,7 +4844,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListCutoverJobsAsyncPager", @@ -4924,7 +4924,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListCutoverJobsPager", @@ -5005,7 +5005,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListDatacenterConnectorsAsyncPager", @@ -5085,7 +5085,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListDatacenterConnectorsPager", @@ -5166,7 +5166,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListGroupsAsyncPager", @@ -5246,7 +5246,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListGroupsPager", @@ -5327,7 +5327,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListMigratingVmsAsyncPager", @@ -5407,7 +5407,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListMigratingVmsPager", @@ -5488,7 +5488,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListReplicationCyclesAsyncPager", @@ -5568,7 +5568,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListReplicationCyclesPager", @@ -5649,7 +5649,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListSourcesAsyncPager", @@ -5729,7 +5729,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListSourcesPager", @@ -5810,7 +5810,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListTargetProjectsAsyncPager", @@ -5890,7 +5890,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListTargetProjectsPager", @@ -5971,7 +5971,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListUtilizationReportsAsyncPager", @@ -6051,7 +6051,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListUtilizationReportsPager", @@ -6128,7 +6128,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6204,7 +6204,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6285,7 +6285,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6365,7 +6365,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6442,7 +6442,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6518,7 +6518,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6599,7 +6599,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6679,7 +6679,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6764,7 +6764,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6848,7 +6848,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6933,7 +6933,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7017,7 +7017,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7102,7 +7102,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7186,7 +7186,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7271,7 +7271,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7355,7 +7355,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7432,7 +7432,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7508,7 +7508,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-vm-migration/tests/unit/gapic/vmmigration_v1/test_vm_migration.py b/packages/google-cloud-vm-migration/tests/unit/gapic/vmmigration_v1/test_vm_migration.py index 91ebe564e9e1..8ec167e7c6b2 100644 --- a/packages/google-cloud-vm-migration/tests/unit/gapic/vmmigration_v1/test_vm_migration.py +++ b/packages/google-cloud-vm-migration/tests/unit/gapic/vmmigration_v1/test_vm_migration.py @@ -18739,6 +18739,7 @@ def test_list_sources_rest_required_fields(request_type=vmmigration.ListSourcesR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_sources(request) @@ -18805,6 +18806,7 @@ def test_list_sources_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_sources(**mock_args) @@ -18994,6 +18996,7 @@ def test_get_source_rest_required_fields(request_type=vmmigration.GetSourceReque response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_source(request) @@ -19039,6 +19042,7 @@ def test_get_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.get_source(**mock_args) @@ -19185,6 +19189,7 @@ def test_create_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.create_source(request) @@ -19252,6 +19257,7 @@ def test_create_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.create_source(**mock_args) @@ -19390,6 +19396,7 @@ def test_update_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.update_source(request) @@ -19446,6 +19453,7 @@ def test_update_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.update_source(**mock_args) @@ -19583,6 +19591,7 @@ def test_delete_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.delete_source(request) @@ -19626,6 +19635,7 @@ def test_delete_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.delete_source(**mock_args) @@ -19758,6 +19768,7 @@ def test_fetch_inventory_rest_required_fields( response_value._content = json_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_inventory(request) @@ -19805,6 +19816,7 @@ def test_fetch_inventory_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.fetch_inventory(**mock_args) @@ -19958,6 +19970,7 @@ def test_list_utilization_reports_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_utilization_reports(request) @@ -20027,6 +20040,7 @@ def test_list_utilization_reports_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_utilization_reports(**mock_args) @@ -20230,6 +20244,7 @@ def test_get_utilization_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.get_utilization_report(request) @@ -20277,6 +20292,7 @@ def test_get_utilization_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.get_utilization_report(**mock_args) @@ -20432,6 +20448,7 @@ def test_create_utilization_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.create_utilization_report(request) @@ -20499,6 +20516,7 @@ def test_create_utilization_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.create_utilization_report(**mock_args) @@ -20640,6 +20658,7 @@ def test_delete_utilization_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.delete_utilization_report(request) @@ -20685,6 +20704,7 @@ def test_delete_utilization_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.delete_utilization_report(**mock_args) @@ -20837,6 +20857,7 @@ def test_list_datacenter_connectors_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_datacenter_connectors(request) @@ -20905,6 +20926,7 @@ def test_list_datacenter_connectors_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_datacenter_connectors(**mock_args) @@ -21106,6 +21128,7 @@ def test_get_datacenter_connector_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_datacenter_connector(request) @@ -21153,6 +21176,7 @@ def test_get_datacenter_connector_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_datacenter_connector(**mock_args) @@ -21308,6 +21332,7 @@ def test_create_datacenter_connector_rest_required_fields( response_value._content = json_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_datacenter_connector(request) @@ -21377,6 +21402,7 @@ def test_create_datacenter_connector_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_datacenter_connector(**mock_args) @@ -21520,6 +21546,7 @@ def test_delete_datacenter_connector_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_datacenter_connector(request) @@ -21565,6 +21592,7 @@ def test_delete_datacenter_connector_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_datacenter_connector(**mock_args) @@ -21700,6 +21728,7 @@ def test_upgrade_appliance_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.upgrade_appliance(request) @@ -21839,6 +21868,7 @@ def test_create_migrating_vm_rest_required_fields( response_value._content = json_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_migrating_vm(request) @@ -21910,6 +21940,7 @@ def test_create_migrating_vm_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_migrating_vm(**mock_args) @@ -22068,6 +22099,7 @@ def test_list_migrating_vms_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_migrating_vms(request) @@ -22137,6 +22169,7 @@ def test_list_migrating_vms_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_migrating_vms(**mock_args) @@ -22337,6 +22370,7 @@ def test_get_migrating_vm_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_migrating_vm(request) @@ -22384,6 +22418,7 @@ def test_get_migrating_vm_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_migrating_vm(**mock_args) @@ -22523,6 +22558,7 @@ def test_update_migrating_vm_rest_required_fields( response_value._content = json_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_migrating_vm(request) @@ -22583,6 +22619,7 @@ def test_update_migrating_vm_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_migrating_vm(**mock_args) @@ -22724,6 +22761,7 @@ def test_delete_migrating_vm_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_migrating_vm(request) @@ -22769,6 +22807,7 @@ def test_delete_migrating_vm_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_migrating_vm(**mock_args) @@ -22902,6 +22941,7 @@ def test_start_migration_rest_required_fields( response_value._content = json_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_migration(request) @@ -22947,6 +22987,7 @@ def test_start_migration_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_migration(**mock_args) @@ -23082,6 +23123,7 @@ def test_resume_migration_rest_required_fields( response_value._content = json_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_migration(request) @@ -23203,6 +23245,7 @@ def test_pause_migration_rest_required_fields( response_value._content = json_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_migration(request) @@ -23328,6 +23371,7 @@ def test_finalize_migration_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.finalize_migration(request) @@ -23373,6 +23417,7 @@ def test_finalize_migration_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.finalize_migration(**mock_args) @@ -23522,6 +23567,7 @@ def test_create_clone_job_rest_required_fields( response_value._content = json_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_clone_job(request) @@ -23593,6 +23639,7 @@ def test_create_clone_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_clone_job(**mock_args) @@ -23734,6 +23781,7 @@ def test_cancel_clone_job_rest_required_fields( response_value._content = json_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_clone_job(request) @@ -23779,6 +23827,7 @@ def test_cancel_clone_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_clone_job(**mock_args) @@ -23926,6 +23975,7 @@ def test_list_clone_jobs_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_clone_jobs(request) @@ -23994,6 +24044,7 @@ def test_list_clone_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_clone_jobs(**mock_args) @@ -24188,6 +24239,7 @@ def test_get_clone_job_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_clone_job(request) @@ -24235,6 +24287,7 @@ def test_get_clone_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_clone_job(**mock_args) @@ -24386,6 +24439,7 @@ def test_create_cutover_job_rest_required_fields( response_value._content = json_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_cutover_job(request) @@ -24457,6 +24511,7 @@ def test_create_cutover_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_cutover_job(**mock_args) @@ -24600,6 +24655,7 @@ def test_cancel_cutover_job_rest_required_fields( response_value._content = json_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_cutover_job(request) @@ -24645,6 +24701,7 @@ def test_cancel_cutover_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_cutover_job(**mock_args) @@ -24794,6 +24851,7 @@ def test_list_cutover_jobs_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_cutover_jobs(request) @@ -24862,6 +24920,7 @@ def test_list_cutover_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_cutover_jobs(**mock_args) @@ -25058,6 +25117,7 @@ def test_get_cutover_job_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_cutover_job(request) @@ -25105,6 +25165,7 @@ def test_get_cutover_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_cutover_job(**mock_args) @@ -25250,6 +25311,7 @@ def test_list_groups_rest_required_fields(request_type=vmmigration.ListGroupsReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_groups(request) @@ -25316,6 +25378,7 @@ def test_list_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_groups(**mock_args) @@ -25505,6 +25568,7 @@ def test_get_group_rest_required_fields(request_type=vmmigration.GetGroupRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_group(request) @@ -25550,6 +25614,7 @@ def test_get_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_group(**mock_args) @@ -25694,6 +25759,7 @@ def test_create_group_rest_required_fields(request_type=vmmigration.CreateGroupR response_value._content = json_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_group(request) @@ -25759,6 +25825,7 @@ def test_create_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.create_group(**mock_args) @@ -25893,6 +25960,7 @@ def test_update_group_rest_required_fields(request_type=vmmigration.UpdateGroupR response_value._content = json_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_group(request) @@ -25947,6 +26015,7 @@ def test_update_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_group(**mock_args) @@ -26080,6 +26149,7 @@ def test_delete_group_rest_required_fields(request_type=vmmigration.DeleteGroupR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_group(request) @@ -26123,6 +26193,7 @@ def test_delete_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.delete_group(**mock_args) @@ -26259,6 +26330,7 @@ def test_add_group_migration_rest_required_fields( response_value._content = json_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_group_migration(request) @@ -26302,6 +26374,7 @@ def test_add_group_migration_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_group_migration(**mock_args) @@ -26440,6 +26513,7 @@ def test_remove_group_migration_rest_required_fields( response_value._content = json_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_group_migration(request) @@ -26483,6 +26557,7 @@ def test_remove_group_migration_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_group_migration(**mock_args) @@ -26634,6 +26709,7 @@ def test_list_target_projects_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_target_projects(request) @@ -26700,6 +26776,7 @@ def test_list_target_projects_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_target_projects(**mock_args) @@ -26898,6 +26975,7 @@ def test_get_target_project_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_target_project(request) @@ -26945,6 +27023,7 @@ def test_get_target_project_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_target_project(**mock_args) @@ -27097,6 +27176,7 @@ def test_create_target_project_rest_required_fields( response_value._content = json_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_target_project(request) @@ -27162,6 +27242,7 @@ def test_create_target_project_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_target_project(**mock_args) @@ -27304,6 +27385,7 @@ def test_update_target_project_rest_required_fields( response_value._content = json_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_target_project(request) @@ -27360,6 +27442,7 @@ def test_update_target_project_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_target_project(**mock_args) @@ -27500,6 +27583,7 @@ def test_delete_target_project_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_target_project(request) @@ -27545,6 +27629,7 @@ def test_delete_target_project_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_target_project(**mock_args) @@ -27697,6 +27782,7 @@ def test_list_replication_cycles_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_replication_cycles(request) @@ -27765,6 +27851,7 @@ def test_list_replication_cycles_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_replication_cycles(**mock_args) @@ -27966,6 +28053,7 @@ def test_get_replication_cycle_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_replication_cycle(request) @@ -28013,6 +28101,7 @@ def test_get_replication_cycle_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_replication_cycle(**mock_args) @@ -30481,6 +30570,7 @@ def test_list_sources_rest_bad_request(request_type=vmmigration.ListSourcesReque response_value.status_code = 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_sources(request) @@ -30517,6 +30607,7 @@ def test_list_sources_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_sources(request) # Establish that the response is the type that we expect. @@ -30556,6 +30647,7 @@ def test_list_sources_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmmigration.ListSourcesResponse.to_json( vmmigration.ListSourcesResponse() ) @@ -30600,6 +30692,7 @@ def test_get_source_rest_bad_request(request_type=vmmigration.GetSourceRequest): response_value.status_code = 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_source(request) @@ -30636,6 +30729,7 @@ def test_get_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.get_source(request) # Establish that the response is the type that we expect. @@ -30675,6 +30769,7 @@ def test_get_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 = vmmigration.Source.to_json(vmmigration.Source()) req.return_value.content = return_value @@ -30717,6 +30812,7 @@ def test_create_source_rest_bad_request(request_type=vmmigration.CreateSourceReq response_value.status_code = 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_source(request) @@ -30852,6 +30948,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_source(request) # Establish that the response is the type that we expect. @@ -30893,6 +30990,7 @@ def test_create_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 @@ -30937,6 +31035,7 @@ def test_update_source_rest_bad_request(request_type=vmmigration.UpdateSourceReq response_value.status_code = 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_source(request) @@ -31074,6 +31173,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_source(request) # Establish that the response is the type that we expect. @@ -31115,6 +31215,7 @@ def test_update_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 @@ -31157,6 +31258,7 @@ def test_delete_source_rest_bad_request(request_type=vmmigration.DeleteSourceReq response_value.status_code = 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_source(request) @@ -31187,6 +31289,7 @@ def test_delete_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.delete_source(request) # Establish that the response is the type that we expect. @@ -31228,6 +31331,7 @@ def test_delete_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 @@ -31272,6 +31376,7 @@ def test_fetch_inventory_rest_bad_request( response_value.status_code = 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_inventory(request) @@ -31305,6 +31410,7 @@ def test_fetch_inventory_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_inventory(request) # Establish that the response is the type that we expect. @@ -31344,6 +31450,7 @@ def test_fetch_inventory_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmmigration.FetchInventoryResponse.to_json( vmmigration.FetchInventoryResponse() ) @@ -31390,6 +31497,7 @@ def test_list_utilization_reports_rest_bad_request( response_value.status_code = 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_utilization_reports(request) @@ -31426,6 +31534,7 @@ def test_list_utilization_reports_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_utilization_reports(request) # Establish that the response is the type that we expect. @@ -31467,6 +31576,7 @@ def test_list_utilization_reports_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmmigration.ListUtilizationReportsResponse.to_json( vmmigration.ListUtilizationReportsResponse() ) @@ -31515,6 +31625,7 @@ def test_get_utilization_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.get_utilization_report(request) @@ -31556,6 +31667,7 @@ def test_get_utilization_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.get_utilization_report(request) # Establish that the response is the type that we expect. @@ -31600,6 +31712,7 @@ def test_get_utilization_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 = vmmigration.UtilizationReport.to_json( vmmigration.UtilizationReport() ) @@ -31646,6 +31759,7 @@ def test_create_utilization_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.create_utilization_report(request) @@ -31794,6 +31908,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_utilization_report(request) # Establish that the response is the type that we expect. @@ -31835,6 +31950,7 @@ def test_create_utilization_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -31881,6 +31997,7 @@ def test_delete_utilization_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.delete_utilization_report(request) @@ -31913,6 +32030,7 @@ def test_delete_utilization_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.delete_utilization_report(request) # Establish that the response is the type that we expect. @@ -31954,6 +32072,7 @@ def test_delete_utilization_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -31998,6 +32117,7 @@ def test_list_datacenter_connectors_rest_bad_request( response_value.status_code = 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_datacenter_connectors(request) @@ -32034,6 +32154,7 @@ def test_list_datacenter_connectors_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_datacenter_connectors(request) # Establish that the response is the type that we expect. @@ -32075,6 +32196,7 @@ def test_list_datacenter_connectors_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmmigration.ListDatacenterConnectorsResponse.to_json( vmmigration.ListDatacenterConnectorsResponse() ) @@ -32123,6 +32245,7 @@ def test_get_datacenter_connector_rest_bad_request( response_value.status_code = 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_datacenter_connector(request) @@ -32167,6 +32290,7 @@ def test_get_datacenter_connector_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_datacenter_connector(request) # Establish that the response is the type that we expect. @@ -32217,6 +32341,7 @@ def test_get_datacenter_connector_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmmigration.DatacenterConnector.to_json( vmmigration.DatacenterConnector() ) @@ -32263,6 +32388,7 @@ def test_create_datacenter_connector_rest_bad_request( response_value.status_code = 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_datacenter_connector(request) @@ -32403,6 +32529,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_datacenter_connector(request) # Establish that the response is the type that we expect. @@ -32444,6 +32571,7 @@ def test_create_datacenter_connector_rest_interceptors(null_interceptor): req.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 @@ -32490,6 +32618,7 @@ def test_delete_datacenter_connector_rest_bad_request( response_value.status_code = 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_datacenter_connector(request) @@ -32522,6 +32651,7 @@ def test_delete_datacenter_connector_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_datacenter_connector(request) # Establish that the response is the type that we expect. @@ -32563,6 +32693,7 @@ def test_delete_datacenter_connector_rest_interceptors(null_interceptor): req.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 @@ -32609,6 +32740,7 @@ def test_upgrade_appliance_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.upgrade_appliance(request) @@ -32641,6 +32773,7 @@ def test_upgrade_appliance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.upgrade_appliance(request) # Establish that the response is the type that we expect. @@ -32682,6 +32815,7 @@ def test_upgrade_appliance_rest_interceptors(null_interceptor): req.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 @@ -32726,6 +32860,7 @@ def test_create_migrating_vm_rest_bad_request( response_value.status_code = 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_migrating_vm(request) @@ -32982,6 +33117,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_migrating_vm(request) # Establish that the response is the type that we expect. @@ -33023,6 +33159,7 @@ def test_create_migrating_vm_rest_interceptors(null_interceptor): req.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 @@ -33067,6 +33204,7 @@ def test_list_migrating_vms_rest_bad_request( response_value.status_code = 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_migrating_vms(request) @@ -33103,6 +33241,7 @@ def test_list_migrating_vms_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_migrating_vms(request) # Establish that the response is the type that we expect. @@ -33144,6 +33283,7 @@ def test_list_migrating_vms_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmmigration.ListMigratingVmsResponse.to_json( vmmigration.ListMigratingVmsResponse() ) @@ -33192,6 +33332,7 @@ def test_get_migrating_vm_rest_bad_request( response_value.status_code = 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_migrating_vm(request) @@ -33234,6 +33375,7 @@ def test_get_migrating_vm_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_migrating_vm(request) # Establish that the response is the type that we expect. @@ -33279,6 +33421,7 @@ def test_get_migrating_vm_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmmigration.MigratingVm.to_json(vmmigration.MigratingVm()) req.return_value.content = return_value @@ -33327,6 +33470,7 @@ def test_update_migrating_vm_rest_bad_request( response_value.status_code = 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_migrating_vm(request) @@ -33587,6 +33731,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_migrating_vm(request) # Establish that the response is the type that we expect. @@ -33628,6 +33773,7 @@ def test_update_migrating_vm_rest_interceptors(null_interceptor): req.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 @@ -33674,6 +33820,7 @@ def test_delete_migrating_vm_rest_bad_request( response_value.status_code = 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_migrating_vm(request) @@ -33706,6 +33853,7 @@ def test_delete_migrating_vm_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_migrating_vm(request) # Establish that the response is the type that we expect. @@ -33747,6 +33895,7 @@ def test_delete_migrating_vm_rest_interceptors(null_interceptor): req.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 @@ -33793,6 +33942,7 @@ def test_start_migration_rest_bad_request( response_value.status_code = 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_migration(request) @@ -33825,6 +33975,7 @@ def test_start_migration_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_migration(request) # Establish that the response is the type that we expect. @@ -33866,6 +34017,7 @@ def test_start_migration_rest_interceptors(null_interceptor): req.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 @@ -33912,6 +34064,7 @@ def test_resume_migration_rest_bad_request( response_value.status_code = 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_migration(request) @@ -33944,6 +34097,7 @@ def test_resume_migration_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_migration(request) # Establish that the response is the type that we expect. @@ -33985,6 +34139,7 @@ def test_resume_migration_rest_interceptors(null_interceptor): req.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 @@ -34031,6 +34186,7 @@ def test_pause_migration_rest_bad_request( response_value.status_code = 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_migration(request) @@ -34063,6 +34219,7 @@ def test_pause_migration_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_migration(request) # Establish that the response is the type that we expect. @@ -34104,6 +34261,7 @@ def test_pause_migration_rest_interceptors(null_interceptor): req.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 @@ -34150,6 +34308,7 @@ def test_finalize_migration_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.finalize_migration(request) @@ -34182,6 +34341,7 @@ def test_finalize_migration_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.finalize_migration(request) # Establish that the response is the type that we expect. @@ -34223,6 +34383,7 @@ def test_finalize_migration_rest_interceptors(null_interceptor): req.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 @@ -34269,6 +34430,7 @@ def test_create_clone_job_rest_bad_request( response_value.status_code = 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_clone_job(request) @@ -34435,6 +34597,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_clone_job(request) # Establish that the response is the type that we expect. @@ -34476,6 +34639,7 @@ def test_create_clone_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 @@ -34522,6 +34686,7 @@ def test_cancel_clone_job_rest_bad_request( response_value.status_code = 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_clone_job(request) @@ -34554,6 +34719,7 @@ def test_cancel_clone_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_clone_job(request) # Establish that the response is the type that we expect. @@ -34595,6 +34761,7 @@ def test_cancel_clone_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 @@ -34641,6 +34808,7 @@ def test_list_clone_jobs_rest_bad_request( response_value.status_code = 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_clone_jobs(request) @@ -34679,6 +34847,7 @@ def test_list_clone_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_clone_jobs(request) # Establish that the response is the type that we expect. @@ -34720,6 +34889,7 @@ def test_list_clone_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 = vmmigration.ListCloneJobsResponse.to_json( vmmigration.ListCloneJobsResponse() ) @@ -34766,6 +34936,7 @@ def test_get_clone_job_rest_bad_request(request_type=vmmigration.GetCloneJobRequ response_value.status_code = 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_clone_job(request) @@ -34804,6 +34975,7 @@ def test_get_clone_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_clone_job(request) # Establish that the response is the type that we expect. @@ -34843,6 +35015,7 @@ def test_get_clone_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 = vmmigration.CloneJob.to_json(vmmigration.CloneJob()) req.return_value.content = return_value @@ -34889,6 +35062,7 @@ def test_create_cutover_job_rest_bad_request( response_value.status_code = 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_cutover_job(request) @@ -35082,6 +35256,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_cutover_job(request) # Establish that the response is the type that we expect. @@ -35123,6 +35298,7 @@ def test_create_cutover_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 @@ -35169,6 +35345,7 @@ def test_cancel_cutover_job_rest_bad_request( response_value.status_code = 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_cutover_job(request) @@ -35201,6 +35378,7 @@ def test_cancel_cutover_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_cutover_job(request) # Establish that the response is the type that we expect. @@ -35242,6 +35420,7 @@ def test_cancel_cutover_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 @@ -35288,6 +35467,7 @@ def test_list_cutover_jobs_rest_bad_request( response_value.status_code = 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_cutover_jobs(request) @@ -35326,6 +35506,7 @@ def test_list_cutover_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_cutover_jobs(request) # Establish that the response is the type that we expect. @@ -35367,6 +35548,7 @@ def test_list_cutover_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 = vmmigration.ListCutoverJobsResponse.to_json( vmmigration.ListCutoverJobsResponse() ) @@ -35415,6 +35597,7 @@ def test_get_cutover_job_rest_bad_request( response_value.status_code = 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_cutover_job(request) @@ -35455,6 +35638,7 @@ def test_get_cutover_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_cutover_job(request) # Establish that the response is the type that we expect. @@ -35498,6 +35682,7 @@ def test_get_cutover_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 = vmmigration.CutoverJob.to_json(vmmigration.CutoverJob()) req.return_value.content = return_value @@ -35540,6 +35725,7 @@ def test_list_groups_rest_bad_request(request_type=vmmigration.ListGroupsRequest response_value.status_code = 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_groups(request) @@ -35576,6 +35762,7 @@ def test_list_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_groups(request) # Establish that the response is the type that we expect. @@ -35615,6 +35802,7 @@ def test_list_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 = vmmigration.ListGroupsResponse.to_json( vmmigration.ListGroupsResponse() ) @@ -35659,6 +35847,7 @@ def test_get_group_rest_bad_request(request_type=vmmigration.GetGroupRequest): response_value.status_code = 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_group(request) @@ -35696,6 +35885,7 @@ def test_get_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_group(request) # Establish that the response is the type that we expect. @@ -35736,6 +35926,7 @@ def test_get_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 = vmmigration.Group.to_json(vmmigration.Group()) req.return_value.content = return_value @@ -35778,6 +35969,7 @@ def test_create_group_rest_bad_request(request_type=vmmigration.CreateGroupReque response_value.status_code = 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_group(request) @@ -35882,6 +36074,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_group(request) # Establish that the response is the type that we expect. @@ -35921,6 +36114,7 @@ def test_create_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -35965,6 +36159,7 @@ def test_update_group_rest_bad_request(request_type=vmmigration.UpdateGroupReque response_value.status_code = 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_group(request) @@ -36071,6 +36266,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_group(request) # Establish that the response is the type that we expect. @@ -36110,6 +36306,7 @@ def test_update_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -36152,6 +36349,7 @@ def test_delete_group_rest_bad_request(request_type=vmmigration.DeleteGroupReque response_value.status_code = 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_group(request) @@ -36182,6 +36380,7 @@ def test_delete_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.delete_group(request) # Establish that the response is the type that we expect. @@ -36221,6 +36420,7 @@ def test_delete_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -36265,6 +36465,7 @@ def test_add_group_migration_rest_bad_request( response_value.status_code = 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_group_migration(request) @@ -36295,6 +36496,7 @@ def test_add_group_migration_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_group_migration(request) # Establish that the response is the type that we expect. @@ -36336,6 +36538,7 @@ def test_add_group_migration_rest_interceptors(null_interceptor): req.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 @@ -36380,6 +36583,7 @@ def test_remove_group_migration_rest_bad_request( response_value.status_code = 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_group_migration(request) @@ -36410,6 +36614,7 @@ def test_remove_group_migration_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_group_migration(request) # Establish that the response is the type that we expect. @@ -36451,6 +36656,7 @@ def test_remove_group_migration_rest_interceptors(null_interceptor): req.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 @@ -36495,6 +36701,7 @@ def test_list_target_projects_rest_bad_request( response_value.status_code = 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_target_projects(request) @@ -36531,6 +36738,7 @@ def test_list_target_projects_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_target_projects(request) # Establish that the response is the type that we expect. @@ -36572,6 +36780,7 @@ def test_list_target_projects_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmmigration.ListTargetProjectsResponse.to_json( vmmigration.ListTargetProjectsResponse() ) @@ -36618,6 +36827,7 @@ def test_get_target_project_rest_bad_request( response_value.status_code = 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_target_project(request) @@ -36655,6 +36865,7 @@ def test_get_target_project_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_target_project(request) # Establish that the response is the type that we expect. @@ -36697,6 +36908,7 @@ def test_get_target_project_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmmigration.TargetProject.to_json(vmmigration.TargetProject()) req.return_value.content = return_value @@ -36741,6 +36953,7 @@ def test_create_target_project_rest_bad_request( response_value.status_code = 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_target_project(request) @@ -36845,6 +37058,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_target_project(request) # Establish that the response is the type that we expect. @@ -36886,6 +37100,7 @@ def test_create_target_project_rest_interceptors(null_interceptor): req.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 @@ -36934,6 +37149,7 @@ def test_update_target_project_rest_bad_request( response_value.status_code = 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_target_project(request) @@ -37042,6 +37258,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_target_project(request) # Establish that the response is the type that we expect. @@ -37083,6 +37300,7 @@ def test_update_target_project_rest_interceptors(null_interceptor): req.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 @@ -37127,6 +37345,7 @@ def test_delete_target_project_rest_bad_request( response_value.status_code = 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_target_project(request) @@ -37157,6 +37376,7 @@ def test_delete_target_project_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_target_project(request) # Establish that the response is the type that we expect. @@ -37198,6 +37418,7 @@ def test_delete_target_project_rest_interceptors(null_interceptor): req.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 @@ -37244,6 +37465,7 @@ def test_list_replication_cycles_rest_bad_request( response_value.status_code = 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_replication_cycles(request) @@ -37282,6 +37504,7 @@ def test_list_replication_cycles_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_replication_cycles(request) # Establish that the response is the type that we expect. @@ -37323,6 +37546,7 @@ def test_list_replication_cycles_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmmigration.ListReplicationCyclesResponse.to_json( vmmigration.ListReplicationCyclesResponse() ) @@ -37371,6 +37595,7 @@ def test_get_replication_cycle_rest_bad_request( response_value.status_code = 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_replication_cycle(request) @@ -37411,6 +37636,7 @@ def test_get_replication_cycle_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_replication_cycle(request) # Establish that the response is the type that we expect. @@ -37454,6 +37680,7 @@ def test_get_replication_cycle_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmmigration.ReplicationCycle.to_json( vmmigration.ReplicationCycle() ) @@ -37500,6 +37727,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) @@ -37530,6 +37758,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) @@ -37558,6 +37787,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) @@ -37588,6 +37818,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) @@ -37618,6 +37849,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) @@ -37648,6 +37880,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) @@ -37678,6 +37911,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) @@ -37708,6 +37942,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) @@ -37738,6 +37973,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) @@ -37768,6 +38004,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) @@ -37798,6 +38035,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) @@ -37828,6 +38066,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-vm-migration/vmmigration-v1-py.tar.gz b/packages/google-cloud-vm-migration/vmmigration-v1-py.tar.gz index fb309dcb5b77..e69de29bb2d1 100644 Binary files a/packages/google-cloud-vm-migration/vmmigration-v1-py.tar.gz and b/packages/google-cloud-vm-migration/vmmigration-v1-py.tar.gz differ diff --git a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine/gapic_version.py b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine/gapic_version.py index 605cecd1f29e..558c8aab67c5 100644 --- a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine/gapic_version.py +++ b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.6.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/gapic_version.py b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/gapic_version.py index 605cecd1f29e..558c8aab67c5 100644 --- a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/gapic_version.py +++ b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.6.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/async_client.py b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/async_client.py index 67020f06701d..e462eeb99f04 100644 --- a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/async_client.py +++ b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/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, VmwareEngineTransport from .transports.grpc_asyncio import VmwareEngineGrpcAsyncIOTransport +try: + from google.api_core import client_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 VmwareEngineAsyncClient: """VMwareEngine manages VMware's private clusters in the Cloud.""" @@ -320,6 +330,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.vmwareengine_v1.VmwareEngineAsyncClient`.", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "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.vmwareengine.v1.VmwareEngine", + "credentialsType": None, + }, + ) + async def list_private_clouds( self, request: Optional[Union[vmwareengine.ListPrivateCloudsRequest, dict]] = None, @@ -327,7 +359,7 @@ async def list_private_clouds( 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.ListPrivateCloudsAsyncPager: r"""Lists ``PrivateCloud`` resources in a given project and location. @@ -376,8 +408,10 @@ async def sample_list_private_clouds(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPrivateCloudsAsyncPager: @@ -452,7 +486,7 @@ async def get_private_cloud( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.PrivateCloud: r"""Retrieves a ``PrivateCloud`` resource by its resource name. @@ -500,8 +534,10 @@ async def sample_get_private_cloud(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.types.PrivateCloud: @@ -565,7 +601,7 @@ async def create_private_cloud( private_cloud_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 ``PrivateCloud`` resource in a given project and location. Private clouds of type ``STANDARD`` and @@ -654,8 +690,10 @@ async def sample_create_private_cloud(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -732,7 +770,7 @@ async def update_private_cloud( 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"""Modifies a ``PrivateCloud`` resource. Only the following fields can be updated: ``description``. Only fields specified in @@ -801,8 +839,10 @@ async def sample_update_private_cloud(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -878,7 +918,7 @@ async def delete_private_cloud( name: Optional[str] = None, retry: OptionalRetry = gapic_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"""Schedules a ``PrivateCloud`` resource for deletion. @@ -947,8 +987,10 @@ async def sample_delete_private_cloud(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1020,7 +1062,7 @@ async def undelete_private_cloud( name: Optional[str] = None, retry: OptionalRetry = gapic_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 a private cloud that was previously scheduled for deletion by ``DeletePrivateCloud``. A ``PrivateCloud`` resource @@ -1076,8 +1118,10 @@ async def sample_undelete_private_cloud(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1149,7 +1193,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 ``Cluster`` resources in a given private cloud. @@ -1198,8 +1242,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.vmwareengine_v1.services.vmware_engine.pagers.ListClustersAsyncPager: @@ -1274,7 +1320,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]]] = (), ) -> vmwareengine_resources.Cluster: r"""Retrieves a ``Cluster`` resource by its resource name. @@ -1322,8 +1368,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.vmwareengine_v1.types.Cluster: @@ -1384,7 +1432,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 private cloud. Creating a new cluster provides additional nodes for use in the parent private @@ -1466,8 +1514,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: @@ -1544,7 +1594,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"""Modifies a ``Cluster`` resource. Only fields specified in ``updateMask`` are applied. @@ -1608,8 +1658,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: @@ -1685,7 +1737,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 ``Cluster`` resource. To avoid unintended data loss, migrate or gracefully shut down any workloads running on the @@ -1740,8 +1792,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: @@ -1820,7 +1874,7 @@ async def list_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.ListNodesAsyncPager: r"""Lists nodes in a given cluster. @@ -1869,8 +1923,10 @@ async def sample_list_nodes(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNodesAsyncPager: @@ -1945,7 +2001,7 @@ async def get_node( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Node: r"""Gets details of a single node. @@ -1990,8 +2046,10 @@ async def sample_get_node(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.types.Node: @@ -2050,7 +2108,7 @@ async def list_external_addresses( 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.ListExternalAddressesAsyncPager: r"""Lists external IP addresses assigned to VMware workload VMs in a given private cloud. @@ -2100,8 +2158,10 @@ async def sample_list_external_addresses(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListExternalAddressesAsyncPager: @@ -2178,7 +2238,7 @@ async def fetch_network_policy_external_addresses( network_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]]] = (), ) -> pagers.FetchNetworkPolicyExternalAddressesAsyncPager: r"""Lists external IP addresses assigned to VMware workload VMs within the scope of the given network @@ -2229,8 +2289,10 @@ async def sample_fetch_network_policy_external_addresses(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.FetchNetworkPolicyExternalAddressesAsyncPager: @@ -2309,7 +2371,7 @@ async def get_external_address( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.ExternalAddress: r"""Gets details of a single external IP address. @@ -2357,8 +2419,10 @@ async def sample_get_external_address(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.types.ExternalAddress: @@ -2424,7 +2488,7 @@ async def create_external_address( external_address_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 ``ExternalAddress`` resource in a given private cloud. The network policy that corresponds to the private cloud @@ -2506,8 +2570,10 @@ async def sample_create_external_address(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2585,7 +2651,7 @@ async def update_external_address( 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 external IP address. Only fields specified in ``update_mask`` are applied. @@ -2650,8 +2716,10 @@ async def sample_update_external_address(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2728,7 +2796,7 @@ async def delete_external_address( name: Optional[str] = None, retry: OptionalRetry = gapic_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 external IP address. When you delete an external IP address, connectivity between the @@ -2783,8 +2851,10 @@ async def sample_delete_external_address(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2863,7 +2933,7 @@ async def list_subnets( 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.ListSubnetsAsyncPager: r"""Lists subnets in a given private cloud. @@ -2912,8 +2982,10 @@ async def sample_list_subnets(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListSubnetsAsyncPager: @@ -2988,7 +3060,7 @@ async def get_subnet( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Subnet: r"""Gets details of a single subnet. @@ -3036,8 +3108,10 @@ async def sample_get_subnet(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.types.Subnet: @@ -3100,7 +3174,7 @@ async def update_subnet( 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 subnet. Only fields specified in ``update_mask`` are applied. @@ -3161,8 +3235,10 @@ async def sample_update_subnet(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3240,7 +3316,7 @@ async def list_external_access_rules( 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.ListExternalAccessRulesAsyncPager: r"""Lists ``ExternalAccessRule`` resources in the specified network policy. @@ -3290,8 +3366,10 @@ async def sample_list_external_access_rules(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListExternalAccessRulesAsyncPager: @@ -3368,7 +3446,7 @@ async def get_external_access_rule( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.ExternalAccessRule: r"""Gets details of a single external access rule. @@ -3416,8 +3494,10 @@ async def sample_get_external_access_rule(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.types.ExternalAccessRule: @@ -3484,7 +3564,7 @@ async def create_external_access_rule( external_access_rule_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 external access rule in a given network policy. @@ -3565,8 +3645,10 @@ async def sample_create_external_access_rule(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3648,7 +3730,7 @@ async def update_external_access_rule( 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 external access rule. Only fields specified in ``update_mask`` are applied. @@ -3708,8 +3790,10 @@ async def sample_update_external_access_rule(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3786,7 +3870,7 @@ async def delete_external_access_rule( name: Optional[str] = None, retry: OptionalRetry = gapic_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 external access rule. @@ -3838,8 +3922,10 @@ async def sample_delete_external_access_rule(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3918,7 +4004,7 @@ async def list_logging_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.ListLoggingServersAsyncPager: r"""Lists logging servers configured for a given private cloud. @@ -3968,8 +4054,10 @@ async def sample_list_logging_servers(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListLoggingServersAsyncPager: @@ -4044,7 +4132,7 @@ async def get_logging_server( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.LoggingServer: r"""Gets details of a logging server. @@ -4092,8 +4180,10 @@ async def sample_get_logging_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.cloud.vmwareengine_v1.types.LoggingServer: @@ -4156,7 +4246,7 @@ async def create_logging_server( logging_server_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"""Create a new logging server for a given private cloud. @@ -4243,8 +4333,10 @@ async def sample_create_logging_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: @@ -4321,7 +4413,7 @@ async def update_logging_server( 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 logging server. Only fields specified in ``update_mask`` are applied. @@ -4386,8 +4478,10 @@ async def sample_update_logging_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: @@ -4463,7 +4557,7 @@ async def delete_logging_server( name: Optional[str] = None, retry: OptionalRetry = gapic_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 logging server. @@ -4515,8 +4609,10 @@ async def sample_delete_logging_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: @@ -4595,7 +4691,7 @@ async def list_node_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.ListNodeTypesAsyncPager: r"""Lists node types @@ -4643,8 +4739,10 @@ async def sample_list_node_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.vmwareengine_v1.services.vmware_engine.pagers.ListNodeTypesAsyncPager: @@ -4719,7 +4817,7 @@ async def get_node_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]]] = (), ) -> vmwareengine_resources.NodeType: r"""Gets details of a single ``NodeType``. @@ -4767,8 +4865,10 @@ async def sample_get_node_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.vmwareengine_v1.types.NodeType: @@ -4827,7 +4927,7 @@ async def show_nsx_credentials( private_cloud: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Credentials: r"""Gets details of credentials for NSX appliance. @@ -4875,8 +4975,10 @@ async def sample_show_nsx_credentials(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.types.Credentials: @@ -4939,7 +5041,7 @@ async def show_vcenter_credentials( private_cloud: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Credentials: r"""Gets details of credentials for Vcenter appliance. @@ -4987,8 +5089,10 @@ async def sample_show_vcenter_credentials(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.types.Credentials: @@ -5049,7 +5153,7 @@ async def reset_nsx_credentials( private_cloud: Optional[str] = None, retry: OptionalRetry = gapic_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"""Resets credentials of the NSX appliance. @@ -5101,8 +5205,10 @@ async def sample_reset_nsx_credentials(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -5178,7 +5284,7 @@ async def reset_vcenter_credentials( private_cloud: Optional[str] = None, retry: OptionalRetry = gapic_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"""Resets credentials of the Vcenter appliance. @@ -5230,8 +5336,10 @@ async def sample_reset_vcenter_credentials(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -5305,7 +5413,7 @@ async def get_dns_forwarding( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.DnsForwarding: r"""Gets details of the ``DnsForwarding`` config. @@ -5353,8 +5461,10 @@ async def sample_get_dns_forwarding(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.types.DnsForwarding: @@ -5419,7 +5529,7 @@ async def update_dns_forwarding( 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 the ``DnsForwarding`` config, like associated domains. Only fields specified in ``update_mask`` are @@ -5485,8 +5595,10 @@ async def sample_update_dns_forwarding(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -5563,7 +5675,7 @@ async def get_network_peering( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.NetworkPeering: r"""Retrieves a ``NetworkPeering`` resource by its resource name. The resource contains details of the network peering, such as @@ -5615,8 +5727,10 @@ async def sample_get_network_peering(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.types.NetworkPeering: @@ -5675,7 +5789,7 @@ async def list_network_peerings( 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.ListNetworkPeeringsAsyncPager: r"""Lists ``NetworkPeering`` resources in a given project. NetworkPeering is a global resource and location can only be @@ -5725,8 +5839,10 @@ async def sample_list_network_peerings(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNetworkPeeringsAsyncPager: @@ -5803,7 +5919,7 @@ async def create_network_peering( network_peering_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 peering between the peer network and VMware Engine network provided in a ``NetworkPeering`` resource. @@ -5892,8 +6008,10 @@ async def sample_create_network_peering(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -5969,7 +6087,7 @@ async def delete_network_peering( name: Optional[str] = None, retry: OptionalRetry = gapic_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 ``NetworkPeering`` resource. When a network peering is deleted for a VMware Engine network, the peer network becomes @@ -6024,8 +6142,10 @@ async def sample_delete_network_peering(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -6105,7 +6225,7 @@ async def update_network_peering( 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"""Modifies a ``NetworkPeering`` resource. Only the ``description`` field can be updated. Only fields specified in ``updateMask`` @@ -6173,8 +6293,10 @@ async def sample_update_network_peering(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -6250,7 +6372,7 @@ async def list_peering_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.ListPeeringRoutesAsyncPager: r"""Lists the network peering routes exchanged over a peering connection. NetworkPeering is a global resource @@ -6301,8 +6423,10 @@ async def sample_list_peering_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.vmwareengine_v1.services.vmware_engine.pagers.ListPeeringRoutesAsyncPager: @@ -6381,7 +6505,7 @@ async def create_hcx_activation_key( hcx_activation_key_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 HCX activation key in a given private cloud. @@ -6463,8 +6587,10 @@ async def sample_create_hcx_activation_key(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -6547,7 +6673,7 @@ async def list_hcx_activation_keys( 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.ListHcxActivationKeysAsyncPager: r"""Lists ``HcxActivationKey`` resources in a given private cloud. @@ -6596,8 +6722,10 @@ async def sample_list_hcx_activation_keys(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListHcxActivationKeysAsyncPager: @@ -6672,7 +6800,7 @@ async def get_hcx_activation_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]]] = (), ) -> vmwareengine_resources.HcxActivationKey: r"""Retrieves a ``HcxActivationKey`` resource by its resource name. @@ -6720,8 +6848,10 @@ async def sample_get_hcx_activation_key(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.types.HcxActivationKey: @@ -6788,7 +6918,7 @@ async def get_network_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.NetworkPolicy: r"""Retrieves a ``NetworkPolicy`` resource by its resource name. @@ -6836,8 +6966,10 @@ async def sample_get_network_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.cloud.vmwareengine_v1.types.NetworkPolicy: @@ -6907,7 +7039,7 @@ async def list_network_policies( 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.ListNetworkPoliciesAsyncPager: r"""Lists ``NetworkPolicy`` resources in a specified project and location. @@ -6956,8 +7088,10 @@ async def sample_list_network_policies(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNetworkPoliciesAsyncPager: @@ -7034,7 +7168,7 @@ async def create_network_policy( network_policy_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 policy in a given VMware Engine network of a project and location (region). A new @@ -7120,8 +7254,10 @@ async def sample_create_network_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.api_core.operation_async.AsyncOperation: @@ -7203,7 +7339,7 @@ async def update_network_policy( 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"""Modifies a ``NetworkPolicy`` resource. Only the following fields can be updated: ``internet_access``, ``external_ip``, @@ -7276,8 +7412,10 @@ async def sample_update_network_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.api_core.operation_async.AsyncOperation: @@ -7358,7 +7496,7 @@ async def delete_network_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_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 ``NetworkPolicy`` resource. A network policy cannot be deleted when ``NetworkService.state`` is set to ``RECONCILING`` @@ -7412,8 +7550,10 @@ async def sample_delete_network_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.api_core.operation_async.AsyncOperation: @@ -7494,7 +7634,7 @@ async def list_management_dns_zone_bindings( 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.ListManagementDnsZoneBindingsAsyncPager: r"""Lists Consumer VPCs bound to Management DNS Zone of a given private cloud. @@ -7544,8 +7684,10 @@ async def sample_list_management_dns_zone_bindings(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListManagementDnsZoneBindingsAsyncPager: @@ -7622,7 +7764,7 @@ async def get_management_dns_zone_binding( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.ManagementDnsZoneBinding: r"""Retrieves a 'ManagementDnsZoneBinding' resource by its resource name. @@ -7671,8 +7813,10 @@ async def sample_get_management_dns_zone_binding(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.types.ManagementDnsZoneBinding: @@ -7746,7 +7890,7 @@ async def create_management_dns_zone_binding( management_dns_zone_binding_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 ``ManagementDnsZoneBinding`` resource in a private cloud. This RPC creates the DNS binding and the resource that @@ -7837,8 +7981,10 @@ async def sample_create_management_dns_zone_binding(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -7925,7 +8071,7 @@ async def update_management_dns_zone_binding( 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 ``ManagementDnsZoneBinding`` resource. Only fields specified in ``update_mask`` are applied. @@ -7989,8 +8135,10 @@ async def sample_update_management_dns_zone_binding(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -8077,7 +8225,7 @@ async def delete_management_dns_zone_binding( name: Optional[str] = None, retry: OptionalRetry = gapic_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 ``ManagementDnsZoneBinding`` resource. When a management DNS zone binding is deleted, the corresponding @@ -8132,8 +8280,10 @@ async def sample_delete_management_dns_zone_binding(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -8214,7 +8364,7 @@ async def repair_management_dns_zone_binding( name: Optional[str] = None, retry: OptionalRetry = gapic_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"""Retries to create a ``ManagementDnsZoneBinding`` resource that is in failed state. @@ -8267,8 +8417,10 @@ async def sample_repair_management_dns_zone_binding(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -8350,7 +8502,7 @@ async def create_vmware_engine_network( vmware_engine_network_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 VMware Engine network that can be used by a private cloud. @@ -8440,8 +8592,10 @@ async def sample_create_vmware_engine_network(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -8523,7 +8677,7 @@ async def update_vmware_engine_network( 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"""Modifies a VMware Engine network resource. Only the following fields can be updated: ``description``. Only fields specified in @@ -8589,8 +8743,10 @@ async def sample_update_vmware_engine_network(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -8667,7 +8823,7 @@ async def delete_vmware_engine_network( name: Optional[str] = None, retry: OptionalRetry = gapic_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 ``VmwareEngineNetwork`` resource. You can only delete a VMware Engine network after all resources that refer to it are @@ -8722,8 +8878,10 @@ async def sample_delete_vmware_engine_network(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -8804,7 +8962,7 @@ async def get_vmware_engine_network( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.VmwareEngineNetwork: r"""Retrieves a ``VmwareEngineNetwork`` resource by its resource name. The resource contains details of the VMware Engine @@ -8856,8 +9014,10 @@ async def sample_get_vmware_engine_network(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.types.VmwareEngineNetwork: @@ -8921,7 +9081,7 @@ async def list_vmware_engine_networks( 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.ListVmwareEngineNetworksAsyncPager: r"""Lists ``VmwareEngineNetwork`` resources in a given project and location. @@ -8970,8 +9130,10 @@ async def sample_list_vmware_engine_networks(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListVmwareEngineNetworksAsyncPager: @@ -9050,7 +9212,7 @@ async def create_private_connection( private_connection_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 private connection that can be used for accessing private Clouds. @@ -9136,8 +9298,10 @@ async def sample_create_private_connection(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -9212,7 +9376,7 @@ async def get_private_connection( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.PrivateConnection: r"""Retrieves a ``PrivateConnection`` resource by its resource name. The resource contains details of the private connection, such as @@ -9262,8 +9426,10 @@ async def sample_get_private_connection(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.types.PrivateConnection: @@ -9327,7 +9493,7 @@ async def list_private_connections( 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.ListPrivateConnectionsAsyncPager: r"""Lists ``PrivateConnection`` resources in a given project and location. @@ -9376,8 +9542,10 @@ async def sample_list_private_connections(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPrivateConnectionsAsyncPager: @@ -9455,7 +9623,7 @@ async def update_private_connection( 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"""Modifies a ``PrivateConnection`` resource. Only ``description`` and ``routing_mode`` fields can be updated. Only fields @@ -9522,8 +9690,10 @@ async def sample_update_private_connection(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -9600,7 +9770,7 @@ async def delete_private_connection( name: Optional[str] = None, retry: OptionalRetry = gapic_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 ``PrivateConnection`` resource. When a private connection is deleted for a VMware Engine network, the connected @@ -9654,8 +9824,10 @@ async def sample_delete_private_connection(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -9736,7 +9908,7 @@ async def list_private_connection_peering_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.ListPrivateConnectionPeeringRoutesAsyncPager: r"""Lists the private connection routes exchanged over a peering connection. @@ -9786,8 +9958,10 @@ async def sample_list_private_connection_peering_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.vmwareengine_v1.services.vmware_engine.pagers.ListPrivateConnectionPeeringRoutesAsyncPager: @@ -9867,7 +10041,7 @@ async def grant_dns_bind_permission( principal: Optional[vmwareengine_resources.Principal] = None, retry: OptionalRetry = gapic_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"""Grants the bind permission to the customer provided principal(user / service account) to bind their DNS zone @@ -9939,8 +10113,10 @@ async def sample_grant_dns_bind_permission(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -10014,7 +10190,7 @@ async def get_dns_bind_permission( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.DnsBindPermission: r"""Gets all the principals having bind permission on the intranet VPC associated with the consumer project @@ -10067,8 +10243,10 @@ async def sample_get_dns_bind_permission(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.types.DnsBindPermission: @@ -10135,7 +10313,7 @@ async def revoke_dns_bind_permission( principal: Optional[vmwareengine_resources.Principal] = None, retry: OptionalRetry = gapic_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"""Revokes the bind permission from the customer provided principal(user / service account) on the @@ -10207,8 +10385,10 @@ async def sample_revoke_dns_bind_permission(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -10281,7 +10461,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. @@ -10292,8 +10472,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. @@ -10334,7 +10516,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. @@ -10345,8 +10527,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. @@ -10387,7 +10571,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. @@ -10403,8 +10587,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 """ @@ -10441,7 +10627,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. @@ -10454,8 +10640,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. @@ -10560,7 +10748,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. @@ -10574,8 +10762,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. @@ -10680,7 +10870,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. @@ -10695,8 +10885,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. @@ -10740,7 +10932,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. @@ -10751,8 +10943,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. @@ -10793,7 +10987,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. @@ -10804,8 +10998,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-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/client.py b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/client.py index 18f39a920829..dc91f0f6f43d 100644 --- a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/client.py +++ b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/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 @@ -951,6 +961,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( @@ -1013,6 +1027,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.vmwareengine_v1.VmwareEngineClient`.", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "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.vmwareengine.v1.VmwareEngine", + "credentialsType": None, + }, + ) + def list_private_clouds( self, request: Optional[Union[vmwareengine.ListPrivateCloudsRequest, dict]] = None, @@ -1020,7 +1057,7 @@ def list_private_clouds( 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.ListPrivateCloudsPager: r"""Lists ``PrivateCloud`` resources in a given project and location. @@ -1069,8 +1106,10 @@ def sample_list_private_clouds(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPrivateCloudsPager: @@ -1142,7 +1181,7 @@ def get_private_cloud( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.PrivateCloud: r"""Retrieves a ``PrivateCloud`` resource by its resource name. @@ -1190,8 +1229,10 @@ def sample_get_private_cloud(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.types.PrivateCloud: @@ -1252,7 +1293,7 @@ def create_private_cloud( private_cloud_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 ``PrivateCloud`` resource in a given project and location. Private clouds of type ``STANDARD`` and @@ -1341,8 +1382,10 @@ def sample_create_private_cloud(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1416,7 +1459,7 @@ def update_private_cloud( 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"""Modifies a ``PrivateCloud`` resource. Only the following fields can be updated: ``description``. Only fields specified in @@ -1485,8 +1528,10 @@ def sample_update_private_cloud(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1559,7 +1604,7 @@ def delete_private_cloud( name: Optional[str] = None, retry: OptionalRetry = gapic_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"""Schedules a ``PrivateCloud`` resource for deletion. @@ -1628,8 +1673,10 @@ def sample_delete_private_cloud(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1698,7 +1745,7 @@ def undelete_private_cloud( name: Optional[str] = None, retry: OptionalRetry = gapic_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 private cloud that was previously scheduled for deletion by ``DeletePrivateCloud``. A ``PrivateCloud`` resource @@ -1754,8 +1801,10 @@ def sample_undelete_private_cloud(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1824,7 +1873,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 ``Cluster`` resources in a given private cloud. @@ -1873,8 +1922,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.vmwareengine_v1.services.vmware_engine.pagers.ListClustersPager: @@ -1946,7 +1997,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]]] = (), ) -> vmwareengine_resources.Cluster: r"""Retrieves a ``Cluster`` resource by its resource name. @@ -1994,8 +2045,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.vmwareengine_v1.types.Cluster: @@ -2053,7 +2106,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 private cloud. Creating a new cluster provides additional nodes for use in the parent private @@ -2135,8 +2188,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: @@ -2210,7 +2265,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"""Modifies a ``Cluster`` resource. Only fields specified in ``updateMask`` are applied. @@ -2274,8 +2329,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: @@ -2348,7 +2405,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 ``Cluster`` resource. To avoid unintended data loss, migrate or gracefully shut down any workloads running on the @@ -2403,8 +2460,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: @@ -2480,7 +2539,7 @@ def list_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.ListNodesPager: r"""Lists nodes in a given cluster. @@ -2529,8 +2588,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.vmwareengine_v1.services.vmware_engine.pagers.ListNodesPager: @@ -2602,7 +2663,7 @@ def get_node( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Node: r"""Gets details of a single node. @@ -2647,8 +2708,10 @@ def sample_get_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.types.Node: @@ -2706,7 +2769,7 @@ def list_external_addresses( 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.ListExternalAddressesPager: r"""Lists external IP addresses assigned to VMware workload VMs in a given private cloud. @@ -2756,8 +2819,10 @@ def sample_list_external_addresses(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListExternalAddressesPager: @@ -2831,7 +2896,7 @@ def fetch_network_policy_external_addresses( network_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]]] = (), ) -> pagers.FetchNetworkPolicyExternalAddressesPager: r"""Lists external IP addresses assigned to VMware workload VMs within the scope of the given network @@ -2882,8 +2947,10 @@ def sample_fetch_network_policy_external_addresses(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.FetchNetworkPolicyExternalAddressesPager: @@ -2961,7 +3028,7 @@ def get_external_address( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.ExternalAddress: r"""Gets details of a single external IP address. @@ -3009,8 +3076,10 @@ def sample_get_external_address(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.types.ExternalAddress: @@ -3073,7 +3142,7 @@ def create_external_address( external_address_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 ``ExternalAddress`` resource in a given private cloud. The network policy that corresponds to the private cloud @@ -3155,8 +3224,10 @@ def sample_create_external_address(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3231,7 +3302,7 @@ def update_external_address( 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 external IP address. Only fields specified in ``update_mask`` are applied. @@ -3296,8 +3367,10 @@ def sample_update_external_address(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3371,7 +3444,7 @@ def delete_external_address( name: Optional[str] = None, retry: OptionalRetry = gapic_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 external IP address. When you delete an external IP address, connectivity between the @@ -3426,8 +3499,10 @@ def sample_delete_external_address(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3503,7 +3578,7 @@ def list_subnets( 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.ListSubnetsPager: r"""Lists subnets in a given private cloud. @@ -3552,8 +3627,10 @@ def sample_list_subnets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListSubnetsPager: @@ -3625,7 +3702,7 @@ def get_subnet( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Subnet: r"""Gets details of a single subnet. @@ -3673,8 +3750,10 @@ def sample_get_subnet(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.types.Subnet: @@ -3734,7 +3813,7 @@ def update_subnet( 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 subnet. Only fields specified in ``update_mask`` are applied. @@ -3795,8 +3874,10 @@ def sample_update_subnet(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3871,7 +3952,7 @@ def list_external_access_rules( 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.ListExternalAccessRulesPager: r"""Lists ``ExternalAccessRule`` resources in the specified network policy. @@ -3921,8 +4002,10 @@ def sample_list_external_access_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.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListExternalAccessRulesPager: @@ -3998,7 +4081,7 @@ def get_external_access_rule( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.ExternalAccessRule: r"""Gets details of a single external access rule. @@ -4046,8 +4129,10 @@ def sample_get_external_access_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.vmwareengine_v1.types.ExternalAccessRule: @@ -4111,7 +4196,7 @@ def create_external_access_rule( external_access_rule_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 external access rule in a given network policy. @@ -4192,8 +4277,10 @@ def sample_create_external_access_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.operation.Operation: @@ -4274,7 +4361,7 @@ def update_external_access_rule( 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 external access rule. Only fields specified in ``update_mask`` are applied. @@ -4334,8 +4421,10 @@ def sample_update_external_access_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.operation.Operation: @@ -4411,7 +4500,7 @@ def delete_external_access_rule( name: Optional[str] = None, retry: OptionalRetry = gapic_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 external access rule. @@ -4463,8 +4552,10 @@ def sample_delete_external_access_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.operation.Operation: @@ -4542,7 +4633,7 @@ def list_logging_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.ListLoggingServersPager: r"""Lists logging servers configured for a given private cloud. @@ -4592,8 +4683,10 @@ def sample_list_logging_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.vmwareengine_v1.services.vmware_engine.pagers.ListLoggingServersPager: @@ -4665,7 +4758,7 @@ def get_logging_server( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.LoggingServer: r"""Gets details of a logging server. @@ -4713,8 +4806,10 @@ def sample_get_logging_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.cloud.vmwareengine_v1.types.LoggingServer: @@ -4774,7 +4869,7 @@ def create_logging_server( logging_server_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"""Create a new logging server for a given private cloud. @@ -4861,8 +4956,10 @@ def sample_create_logging_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: @@ -4936,7 +5033,7 @@ def update_logging_server( 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 logging server. Only fields specified in ``update_mask`` are applied. @@ -5001,8 +5098,10 @@ def sample_update_logging_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: @@ -5075,7 +5174,7 @@ def delete_logging_server( name: Optional[str] = None, retry: OptionalRetry = gapic_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 logging server. @@ -5127,8 +5226,10 @@ def sample_delete_logging_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: @@ -5204,7 +5305,7 @@ def list_node_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.ListNodeTypesPager: r"""Lists node types @@ -5252,8 +5353,10 @@ def sample_list_node_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.vmwareengine_v1.services.vmware_engine.pagers.ListNodeTypesPager: @@ -5325,7 +5428,7 @@ def get_node_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]]] = (), ) -> vmwareengine_resources.NodeType: r"""Gets details of a single ``NodeType``. @@ -5373,8 +5476,10 @@ def sample_get_node_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.vmwareengine_v1.types.NodeType: @@ -5430,7 +5535,7 @@ def show_nsx_credentials( private_cloud: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Credentials: r"""Gets details of credentials for NSX appliance. @@ -5478,8 +5583,10 @@ def sample_show_nsx_credentials(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.types.Credentials: @@ -5539,7 +5646,7 @@ def show_vcenter_credentials( private_cloud: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Credentials: r"""Gets details of credentials for Vcenter appliance. @@ -5587,8 +5694,10 @@ def sample_show_vcenter_credentials(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.types.Credentials: @@ -5646,7 +5755,7 @@ def reset_nsx_credentials( private_cloud: Optional[str] = None, retry: OptionalRetry = gapic_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"""Resets credentials of the NSX appliance. @@ -5698,8 +5807,10 @@ def sample_reset_nsx_credentials(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -5772,7 +5883,7 @@ def reset_vcenter_credentials( private_cloud: Optional[str] = None, retry: OptionalRetry = gapic_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"""Resets credentials of the Vcenter appliance. @@ -5824,8 +5935,10 @@ def sample_reset_vcenter_credentials(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -5898,7 +6011,7 @@ def get_dns_forwarding( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.DnsForwarding: r"""Gets details of the ``DnsForwarding`` config. @@ -5946,8 +6059,10 @@ def sample_get_dns_forwarding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.types.DnsForwarding: @@ -6009,7 +6124,7 @@ def update_dns_forwarding( 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 the ``DnsForwarding`` config, like associated domains. Only fields specified in ``update_mask`` are @@ -6075,8 +6190,10 @@ def sample_update_dns_forwarding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -6150,7 +6267,7 @@ def get_network_peering( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.NetworkPeering: r"""Retrieves a ``NetworkPeering`` resource by its resource name. The resource contains details of the network peering, such as @@ -6202,8 +6319,10 @@ def sample_get_network_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.cloud.vmwareengine_v1.types.NetworkPeering: @@ -6259,7 +6378,7 @@ def list_network_peerings( 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.ListNetworkPeeringsPager: r"""Lists ``NetworkPeering`` resources in a given project. NetworkPeering is a global resource and location can only be @@ -6309,8 +6428,10 @@ def sample_list_network_peerings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNetworkPeeringsPager: @@ -6384,7 +6505,7 @@ def create_network_peering( network_peering_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 peering between the peer network and VMware Engine network provided in a ``NetworkPeering`` resource. @@ -6473,8 +6594,10 @@ def sample_create_network_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.operation.Operation: @@ -6547,7 +6670,7 @@ def delete_network_peering( name: Optional[str] = None, retry: OptionalRetry = gapic_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 ``NetworkPeering`` resource. When a network peering is deleted for a VMware Engine network, the peer network becomes @@ -6602,8 +6725,10 @@ def sample_delete_network_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.operation.Operation: @@ -6680,7 +6805,7 @@ def update_network_peering( 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"""Modifies a ``NetworkPeering`` resource. Only the ``description`` field can be updated. Only fields specified in ``updateMask`` @@ -6748,8 +6873,10 @@ def sample_update_network_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.operation.Operation: @@ -6822,7 +6949,7 @@ def list_peering_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.ListPeeringRoutesPager: r"""Lists the network peering routes exchanged over a peering connection. NetworkPeering is a global resource @@ -6873,8 +7000,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.vmwareengine_v1.services.vmware_engine.pagers.ListPeeringRoutesPager: @@ -6950,7 +7079,7 @@ def create_hcx_activation_key( hcx_activation_key_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 HCX activation key in a given private cloud. @@ -7032,8 +7161,10 @@ def sample_create_hcx_activation_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.operation.Operation: @@ -7115,7 +7246,7 @@ def list_hcx_activation_keys( 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.ListHcxActivationKeysPager: r"""Lists ``HcxActivationKey`` resources in a given private cloud. @@ -7164,8 +7295,10 @@ def sample_list_hcx_activation_keys(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListHcxActivationKeysPager: @@ -7237,7 +7370,7 @@ def get_hcx_activation_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]]] = (), ) -> vmwareengine_resources.HcxActivationKey: r"""Retrieves a ``HcxActivationKey`` resource by its resource name. @@ -7285,8 +7418,10 @@ def sample_get_hcx_activation_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.cloud.vmwareengine_v1.types.HcxActivationKey: @@ -7350,7 +7485,7 @@ def get_network_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.NetworkPolicy: r"""Retrieves a ``NetworkPolicy`` resource by its resource name. @@ -7398,8 +7533,10 @@ def sample_get_network_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.vmwareengine_v1.types.NetworkPolicy: @@ -7466,7 +7603,7 @@ def list_network_policies( 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.ListNetworkPoliciesPager: r"""Lists ``NetworkPolicy`` resources in a specified project and location. @@ -7515,8 +7652,10 @@ def sample_list_network_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.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNetworkPoliciesPager: @@ -7590,7 +7729,7 @@ def create_network_policy( network_policy_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 policy in a given VMware Engine network of a project and location (region). A new @@ -7676,8 +7815,10 @@ def sample_create_network_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.operation.Operation: @@ -7756,7 +7897,7 @@ def update_network_policy( 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"""Modifies a ``NetworkPolicy`` resource. Only the following fields can be updated: ``internet_access``, ``external_ip``, @@ -7829,8 +7970,10 @@ def sample_update_network_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.operation.Operation: @@ -7908,7 +8051,7 @@ def delete_network_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_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 ``NetworkPolicy`` resource. A network policy cannot be deleted when ``NetworkService.state`` is set to ``RECONCILING`` @@ -7962,8 +8105,10 @@ def sample_delete_network_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.operation.Operation: @@ -8041,7 +8186,7 @@ def list_management_dns_zone_bindings( 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.ListManagementDnsZoneBindingsPager: r"""Lists Consumer VPCs bound to Management DNS Zone of a given private cloud. @@ -8091,8 +8236,10 @@ def sample_list_management_dns_zone_bindings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListManagementDnsZoneBindingsPager: @@ -8168,7 +8315,7 @@ def get_management_dns_zone_binding( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.ManagementDnsZoneBinding: r"""Retrieves a 'ManagementDnsZoneBinding' resource by its resource name. @@ -8217,8 +8364,10 @@ def sample_get_management_dns_zone_binding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.types.ManagementDnsZoneBinding: @@ -8291,7 +8440,7 @@ def create_management_dns_zone_binding( management_dns_zone_binding_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 ``ManagementDnsZoneBinding`` resource in a private cloud. This RPC creates the DNS binding and the resource that @@ -8382,8 +8531,10 @@ def sample_create_management_dns_zone_binding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -8469,7 +8620,7 @@ def update_management_dns_zone_binding( 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 ``ManagementDnsZoneBinding`` resource. Only fields specified in ``update_mask`` are applied. @@ -8533,8 +8684,10 @@ def sample_update_management_dns_zone_binding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -8620,7 +8773,7 @@ def delete_management_dns_zone_binding( name: Optional[str] = None, retry: OptionalRetry = gapic_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 ``ManagementDnsZoneBinding`` resource. When a management DNS zone binding is deleted, the corresponding @@ -8675,8 +8828,10 @@ def sample_delete_management_dns_zone_binding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -8756,7 +8911,7 @@ def repair_management_dns_zone_binding( name: Optional[str] = None, retry: OptionalRetry = gapic_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"""Retries to create a ``ManagementDnsZoneBinding`` resource that is in failed state. @@ -8809,8 +8964,10 @@ def sample_repair_management_dns_zone_binding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -8891,7 +9048,7 @@ def create_vmware_engine_network( vmware_engine_network_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 VMware Engine network that can be used by a private cloud. @@ -8981,8 +9138,10 @@ def sample_create_vmware_engine_network(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -9063,7 +9222,7 @@ def update_vmware_engine_network( 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"""Modifies a VMware Engine network resource. Only the following fields can be updated: ``description``. Only fields specified in @@ -9129,8 +9288,10 @@ def sample_update_vmware_engine_network(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -9206,7 +9367,7 @@ def delete_vmware_engine_network( name: Optional[str] = None, retry: OptionalRetry = gapic_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 ``VmwareEngineNetwork`` resource. You can only delete a VMware Engine network after all resources that refer to it are @@ -9261,8 +9422,10 @@ def sample_delete_vmware_engine_network(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -9342,7 +9505,7 @@ def get_vmware_engine_network( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.VmwareEngineNetwork: r"""Retrieves a ``VmwareEngineNetwork`` resource by its resource name. The resource contains details of the VMware Engine @@ -9394,8 +9557,10 @@ def sample_get_vmware_engine_network(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.types.VmwareEngineNetwork: @@ -9458,7 +9623,7 @@ def list_vmware_engine_networks( 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.ListVmwareEngineNetworksPager: r"""Lists ``VmwareEngineNetwork`` resources in a given project and location. @@ -9507,8 +9672,10 @@ def sample_list_vmware_engine_networks(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListVmwareEngineNetworksPager: @@ -9586,7 +9753,7 @@ def create_private_connection( private_connection_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 private connection that can be used for accessing private Clouds. @@ -9672,8 +9839,10 @@ def sample_create_private_connection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -9747,7 +9916,7 @@ def get_private_connection( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.PrivateConnection: r"""Retrieves a ``PrivateConnection`` resource by its resource name. The resource contains details of the private connection, such as @@ -9797,8 +9966,10 @@ def sample_get_private_connection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.types.PrivateConnection: @@ -9859,7 +10030,7 @@ def list_private_connections( 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.ListPrivateConnectionsPager: r"""Lists ``PrivateConnection`` resources in a given project and location. @@ -9908,8 +10079,10 @@ def sample_list_private_connections(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPrivateConnectionsPager: @@ -9984,7 +10157,7 @@ def update_private_connection( 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"""Modifies a ``PrivateConnection`` resource. Only ``description`` and ``routing_mode`` fields can be updated. Only fields @@ -10051,8 +10224,10 @@ def sample_update_private_connection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -10128,7 +10303,7 @@ def delete_private_connection( name: Optional[str] = None, retry: OptionalRetry = gapic_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 ``PrivateConnection`` resource. When a private connection is deleted for a VMware Engine network, the connected @@ -10182,8 +10357,10 @@ def sample_delete_private_connection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -10263,7 +10440,7 @@ def list_private_connection_peering_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.ListPrivateConnectionPeeringRoutesPager: r"""Lists the private connection routes exchanged over a peering connection. @@ -10313,8 +10490,10 @@ def sample_list_private_connection_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.vmwareengine_v1.services.vmware_engine.pagers.ListPrivateConnectionPeeringRoutesPager: @@ -10393,7 +10572,7 @@ def grant_dns_bind_permission( principal: Optional[vmwareengine_resources.Principal] = None, retry: OptionalRetry = gapic_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"""Grants the bind permission to the customer provided principal(user / service account) to bind their DNS zone @@ -10465,8 +10644,10 @@ def sample_grant_dns_bind_permission(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -10539,7 +10720,7 @@ def get_dns_bind_permission( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.DnsBindPermission: r"""Gets all the principals having bind permission on the intranet VPC associated with the consumer project @@ -10592,8 +10773,10 @@ def sample_get_dns_bind_permission(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vmwareengine_v1.types.DnsBindPermission: @@ -10657,7 +10840,7 @@ def revoke_dns_bind_permission( principal: Optional[vmwareengine_resources.Principal] = None, retry: OptionalRetry = gapic_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"""Revokes the bind permission from the customer provided principal(user / service account) on the @@ -10729,8 +10912,10 @@ def sample_revoke_dns_bind_permission(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -10815,7 +11000,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. @@ -10826,8 +11011,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. @@ -10868,7 +11055,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. @@ -10879,8 +11066,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. @@ -10921,7 +11110,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. @@ -10937,8 +11126,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 """ @@ -10975,7 +11166,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. @@ -10988,8 +11179,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. @@ -11094,7 +11287,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. @@ -11108,8 +11301,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. @@ -11214,7 +11409,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. @@ -11229,8 +11424,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. @@ -11272,7 +11469,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. @@ -11283,8 +11480,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. @@ -11325,7 +11524,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. @@ -11336,8 +11535,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-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/pagers.py b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/pagers.py index 7bcc0c727840..5fe90219b943 100644 --- a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/pagers.py +++ b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/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 = vmwareengine.ListPrivateCloudsRequest(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 = vmwareengine.ListPrivateCloudsRequest(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 = vmwareengine.ListClustersRequest(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 = vmwareengine.ListClustersRequest(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 = vmwareengine.ListNodesRequest(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 = vmwareengine.ListNodesRequest(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 = vmwareengine.ListExternalAddressesRequest(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 = vmwareengine.ListExternalAddressesRequest(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 = vmwareengine.FetchNetworkPolicyExternalAddressesRequest(request) @@ -753,7 +771,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. @@ -767,8 +785,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 = vmwareengine.FetchNetworkPolicyExternalAddressesRequest(request) @@ -833,7 +853,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -847,8 +867,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = vmwareengine.ListSubnetsRequest(request) @@ -907,7 +929,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. @@ -921,8 +943,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 = vmwareengine.ListSubnetsRequest(request) @@ -985,7 +1009,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -999,8 +1023,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = vmwareengine.ListExternalAccessRulesRequest(request) @@ -1059,7 +1085,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. @@ -1073,8 +1099,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 = vmwareengine.ListExternalAccessRulesRequest(request) @@ -1139,7 +1167,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1153,8 +1181,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = vmwareengine.ListLoggingServersRequest(request) @@ -1213,7 +1243,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. @@ -1227,8 +1257,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 = vmwareengine.ListLoggingServersRequest(request) @@ -1291,7 +1323,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1305,8 +1337,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = vmwareengine.ListNodeTypesRequest(request) @@ -1365,7 +1399,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. @@ -1379,8 +1413,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 = vmwareengine.ListNodeTypesRequest(request) @@ -1443,7 +1479,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1457,8 +1493,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = vmwareengine.ListNetworkPeeringsRequest(request) @@ -1517,7 +1555,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. @@ -1531,8 +1569,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 = vmwareengine.ListNetworkPeeringsRequest(request) @@ -1595,7 +1635,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1609,8 +1649,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = vmwareengine.ListPeeringRoutesRequest(request) @@ -1669,7 +1711,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. @@ -1683,8 +1725,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 = vmwareengine.ListPeeringRoutesRequest(request) @@ -1747,7 +1791,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1761,8 +1805,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = vmwareengine.ListHcxActivationKeysRequest(request) @@ -1821,7 +1867,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. @@ -1835,8 +1881,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 = vmwareengine.ListHcxActivationKeysRequest(request) @@ -1899,7 +1947,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1913,8 +1961,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = vmwareengine.ListNetworkPoliciesRequest(request) @@ -1973,7 +2023,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. @@ -1987,8 +2037,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 = vmwareengine.ListNetworkPoliciesRequest(request) @@ -2051,7 +2103,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -2065,8 +2117,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = vmwareengine.ListManagementDnsZoneBindingsRequest(request) @@ -2127,7 +2181,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. @@ -2141,8 +2195,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 = vmwareengine.ListManagementDnsZoneBindingsRequest(request) @@ -2209,7 +2265,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -2223,8 +2279,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = vmwareengine.ListVmwareEngineNetworksRequest(request) @@ -2283,7 +2341,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. @@ -2297,8 +2355,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 = vmwareengine.ListVmwareEngineNetworksRequest(request) @@ -2363,7 +2423,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -2377,8 +2437,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = vmwareengine.ListPrivateConnectionsRequest(request) @@ -2437,7 +2499,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. @@ -2451,8 +2513,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 = vmwareengine.ListPrivateConnectionsRequest(request) @@ -2515,7 +2579,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -2529,8 +2593,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = vmwareengine.ListPrivateConnectionPeeringRoutesRequest(request) @@ -2593,7 +2659,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. @@ -2607,8 +2673,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 = vmwareengine.ListPrivateConnectionPeeringRoutesRequest(request) diff --git a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/transports/grpc.py b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/transports/grpc.py index 52c9a5af483c..b171967dd693 100644 --- a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/transports/grpc.py +++ b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/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.vmwareengine_v1.types import vmwareengine, vmwareengine_resources from .base import DEFAULT_CLIENT_INFO, VmwareEngineTransport +try: + from google.api_core import client_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.vmwareengine.v1.VmwareEngine", + "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.vmwareengine.v1.VmwareEngine", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VmwareEngineGrpcTransport(VmwareEngineTransport): """gRPC backend transport for VmwareEngine. @@ -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_private_clouds( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_private_clouds" not in self._stubs: - self._stubs["list_private_clouds"] = self.grpc_channel.unary_unary( + self._stubs["list_private_clouds"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListPrivateClouds", request_serializer=vmwareengine.ListPrivateCloudsRequest.serialize, response_deserializer=vmwareengine.ListPrivateCloudsResponse.deserialize, @@ -303,7 +391,7 @@ def get_private_cloud( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_private_cloud" not in self._stubs: - self._stubs["get_private_cloud"] = self.grpc_channel.unary_unary( + self._stubs["get_private_cloud"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetPrivateCloud", request_serializer=vmwareengine.GetPrivateCloudRequest.serialize, response_deserializer=vmwareengine_resources.PrivateCloud.deserialize, @@ -335,7 +423,7 @@ def create_private_cloud( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_private_cloud" not in self._stubs: - self._stubs["create_private_cloud"] = self.grpc_channel.unary_unary( + self._stubs["create_private_cloud"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreatePrivateCloud", request_serializer=vmwareengine.CreatePrivateCloudRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -368,7 +456,7 @@ def update_private_cloud( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_private_cloud" not in self._stubs: - self._stubs["update_private_cloud"] = self.grpc_channel.unary_unary( + self._stubs["update_private_cloud"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdatePrivateCloud", request_serializer=vmwareengine.UpdatePrivateCloudRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -411,7 +499,7 @@ def delete_private_cloud( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_private_cloud" not in self._stubs: - self._stubs["delete_private_cloud"] = self.grpc_channel.unary_unary( + self._stubs["delete_private_cloud"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeletePrivateCloud", request_serializer=vmwareengine.DeletePrivateCloudRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -441,7 +529,7 @@ def undelete_private_cloud( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undelete_private_cloud" not in self._stubs: - self._stubs["undelete_private_cloud"] = self.grpc_channel.unary_unary( + self._stubs["undelete_private_cloud"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UndeletePrivateCloud", request_serializer=vmwareengine.UndeletePrivateCloudRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -469,7 +557,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.vmwareengine.v1.VmwareEngine/ListClusters", request_serializer=vmwareengine.ListClustersRequest.serialize, response_deserializer=vmwareengine.ListClustersResponse.deserialize, @@ -495,7 +583,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.vmwareengine.v1.VmwareEngine/GetCluster", request_serializer=vmwareengine.GetClusterRequest.serialize, response_deserializer=vmwareengine_resources.Cluster.deserialize, @@ -524,7 +612,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.vmwareengine.v1.VmwareEngine/CreateCluster", request_serializer=vmwareengine.CreateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -556,7 +644,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.vmwareengine.v1.VmwareEngine/UpdateCluster", request_serializer=vmwareengine.UpdateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -585,7 +673,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.vmwareengine.v1.VmwareEngine/DeleteCluster", request_serializer=vmwareengine.DeleteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -611,7 +699,7 @@ def list_nodes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_nodes" not in self._stubs: - self._stubs["list_nodes"] = self.grpc_channel.unary_unary( + self._stubs["list_nodes"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListNodes", request_serializer=vmwareengine.ListNodesRequest.serialize, response_deserializer=vmwareengine.ListNodesResponse.deserialize, @@ -637,7 +725,7 @@ def get_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_node" not in self._stubs: - self._stubs["get_node"] = self.grpc_channel.unary_unary( + self._stubs["get_node"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetNode", request_serializer=vmwareengine.GetNodeRequest.serialize, response_deserializer=vmwareengine_resources.Node.deserialize, @@ -667,7 +755,7 @@ def list_external_addresses( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_external_addresses" not in self._stubs: - self._stubs["list_external_addresses"] = self.grpc_channel.unary_unary( + self._stubs["list_external_addresses"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListExternalAddresses", request_serializer=vmwareengine.ListExternalAddressesRequest.serialize, response_deserializer=vmwareengine.ListExternalAddressesResponse.deserialize, @@ -701,7 +789,7 @@ def fetch_network_policy_external_addresses( if "fetch_network_policy_external_addresses" not in self._stubs: self._stubs[ "fetch_network_policy_external_addresses" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/FetchNetworkPolicyExternalAddresses", request_serializer=vmwareengine.FetchNetworkPolicyExternalAddressesRequest.serialize, response_deserializer=vmwareengine.FetchNetworkPolicyExternalAddressesResponse.deserialize, @@ -729,7 +817,7 @@ def get_external_address( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_external_address" not in self._stubs: - self._stubs["get_external_address"] = self.grpc_channel.unary_unary( + self._stubs["get_external_address"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetExternalAddress", request_serializer=vmwareengine.GetExternalAddressRequest.serialize, response_deserializer=vmwareengine_resources.ExternalAddress.deserialize, @@ -760,7 +848,7 @@ def create_external_address( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_external_address" not in self._stubs: - self._stubs["create_external_address"] = self.grpc_channel.unary_unary( + self._stubs["create_external_address"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateExternalAddress", request_serializer=vmwareengine.CreateExternalAddressRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -794,7 +882,7 @@ def update_external_address( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_external_address" not in self._stubs: - self._stubs["update_external_address"] = self.grpc_channel.unary_unary( + self._stubs["update_external_address"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateExternalAddress", request_serializer=vmwareengine.UpdateExternalAddressRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -825,7 +913,7 @@ def delete_external_address( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_external_address" not in self._stubs: - self._stubs["delete_external_address"] = self.grpc_channel.unary_unary( + self._stubs["delete_external_address"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteExternalAddress", request_serializer=vmwareengine.DeleteExternalAddressRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -851,7 +939,7 @@ def list_subnets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_subnets" not in self._stubs: - self._stubs["list_subnets"] = self.grpc_channel.unary_unary( + self._stubs["list_subnets"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListSubnets", request_serializer=vmwareengine.ListSubnetsRequest.serialize, response_deserializer=vmwareengine.ListSubnetsResponse.deserialize, @@ -877,7 +965,7 @@ def get_subnet( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_subnet" not in self._stubs: - self._stubs["get_subnet"] = self.grpc_channel.unary_unary( + self._stubs["get_subnet"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetSubnet", request_serializer=vmwareengine.GetSubnetRequest.serialize, response_deserializer=vmwareengine_resources.Subnet.deserialize, @@ -908,7 +996,7 @@ def update_subnet( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_subnet" not in self._stubs: - self._stubs["update_subnet"] = self.grpc_channel.unary_unary( + self._stubs["update_subnet"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateSubnet", request_serializer=vmwareengine.UpdateSubnetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -938,7 +1026,9 @@ def list_external_access_rules( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_external_access_rules" not in self._stubs: - self._stubs["list_external_access_rules"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_external_access_rules" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListExternalAccessRules", request_serializer=vmwareengine.ListExternalAccessRulesRequest.serialize, response_deserializer=vmwareengine.ListExternalAccessRulesResponse.deserialize, @@ -967,7 +1057,7 @@ def get_external_access_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_external_access_rule" not in self._stubs: - self._stubs["get_external_access_rule"] = self.grpc_channel.unary_unary( + self._stubs["get_external_access_rule"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetExternalAccessRule", request_serializer=vmwareengine.GetExternalAccessRuleRequest.serialize, response_deserializer=vmwareengine_resources.ExternalAccessRule.deserialize, @@ -996,7 +1086,9 @@ def create_external_access_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_external_access_rule" not in self._stubs: - self._stubs["create_external_access_rule"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_external_access_rule" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateExternalAccessRule", request_serializer=vmwareengine.CreateExternalAccessRuleRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1025,7 +1117,9 @@ def update_external_access_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_external_access_rule" not in self._stubs: - self._stubs["update_external_access_rule"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_external_access_rule" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateExternalAccessRule", request_serializer=vmwareengine.UpdateExternalAccessRuleRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1053,7 +1147,9 @@ def delete_external_access_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_external_access_rule" not in self._stubs: - self._stubs["delete_external_access_rule"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_external_access_rule" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteExternalAccessRule", request_serializer=vmwareengine.DeleteExternalAccessRuleRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1083,7 +1179,7 @@ def list_logging_servers( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_logging_servers" not in self._stubs: - self._stubs["list_logging_servers"] = self.grpc_channel.unary_unary( + self._stubs["list_logging_servers"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListLoggingServers", request_serializer=vmwareengine.ListLoggingServersRequest.serialize, response_deserializer=vmwareengine.ListLoggingServersResponse.deserialize, @@ -1111,7 +1207,7 @@ def get_logging_server( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_logging_server" not in self._stubs: - self._stubs["get_logging_server"] = self.grpc_channel.unary_unary( + self._stubs["get_logging_server"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetLoggingServer", request_serializer=vmwareengine.GetLoggingServerRequest.serialize, response_deserializer=vmwareengine_resources.LoggingServer.deserialize, @@ -1138,7 +1234,7 @@ def create_logging_server( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_logging_server" not in self._stubs: - self._stubs["create_logging_server"] = self.grpc_channel.unary_unary( + self._stubs["create_logging_server"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateLoggingServer", request_serializer=vmwareengine.CreateLoggingServerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1165,7 +1261,7 @@ def update_logging_server( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_logging_server" not in self._stubs: - self._stubs["update_logging_server"] = self.grpc_channel.unary_unary( + self._stubs["update_logging_server"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateLoggingServer", request_serializer=vmwareengine.UpdateLoggingServerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1191,7 +1287,7 @@ def delete_logging_server( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_logging_server" not in self._stubs: - self._stubs["delete_logging_server"] = self.grpc_channel.unary_unary( + self._stubs["delete_logging_server"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteLoggingServer", request_serializer=vmwareengine.DeleteLoggingServerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1219,7 +1315,7 @@ def list_node_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_node_types" not in self._stubs: - self._stubs["list_node_types"] = self.grpc_channel.unary_unary( + self._stubs["list_node_types"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListNodeTypes", request_serializer=vmwareengine.ListNodeTypesRequest.serialize, response_deserializer=vmwareengine.ListNodeTypesResponse.deserialize, @@ -1245,7 +1341,7 @@ def get_node_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_node_type" not in self._stubs: - self._stubs["get_node_type"] = self.grpc_channel.unary_unary( + self._stubs["get_node_type"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetNodeType", request_serializer=vmwareengine.GetNodeTypeRequest.serialize, response_deserializer=vmwareengine_resources.NodeType.deserialize, @@ -1273,7 +1369,7 @@ def show_nsx_credentials( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "show_nsx_credentials" not in self._stubs: - self._stubs["show_nsx_credentials"] = self.grpc_channel.unary_unary( + self._stubs["show_nsx_credentials"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ShowNsxCredentials", request_serializer=vmwareengine.ShowNsxCredentialsRequest.serialize, response_deserializer=vmwareengine_resources.Credentials.deserialize, @@ -1301,7 +1397,7 @@ def show_vcenter_credentials( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "show_vcenter_credentials" not in self._stubs: - self._stubs["show_vcenter_credentials"] = self.grpc_channel.unary_unary( + self._stubs["show_vcenter_credentials"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ShowVcenterCredentials", request_serializer=vmwareengine.ShowVcenterCredentialsRequest.serialize, response_deserializer=vmwareengine_resources.Credentials.deserialize, @@ -1327,7 +1423,7 @@ def reset_nsx_credentials( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reset_nsx_credentials" not in self._stubs: - self._stubs["reset_nsx_credentials"] = self.grpc_channel.unary_unary( + self._stubs["reset_nsx_credentials"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ResetNsxCredentials", request_serializer=vmwareengine.ResetNsxCredentialsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1355,7 +1451,7 @@ def reset_vcenter_credentials( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reset_vcenter_credentials" not in self._stubs: - self._stubs["reset_vcenter_credentials"] = self.grpc_channel.unary_unary( + self._stubs["reset_vcenter_credentials"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ResetVcenterCredentials", request_serializer=vmwareengine.ResetVcenterCredentialsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1383,7 +1479,7 @@ def get_dns_forwarding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_dns_forwarding" not in self._stubs: - self._stubs["get_dns_forwarding"] = self.grpc_channel.unary_unary( + self._stubs["get_dns_forwarding"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetDnsForwarding", request_serializer=vmwareengine.GetDnsForwardingRequest.serialize, response_deserializer=vmwareengine_resources.DnsForwarding.deserialize, @@ -1411,7 +1507,7 @@ def update_dns_forwarding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_dns_forwarding" not in self._stubs: - self._stubs["update_dns_forwarding"] = self.grpc_channel.unary_unary( + self._stubs["update_dns_forwarding"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateDnsForwarding", request_serializer=vmwareengine.UpdateDnsForwardingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1443,7 +1539,7 @@ def get_network_peering( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_network_peering" not in self._stubs: - self._stubs["get_network_peering"] = self.grpc_channel.unary_unary( + self._stubs["get_network_peering"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetNetworkPeering", request_serializer=vmwareengine.GetNetworkPeeringRequest.serialize, response_deserializer=vmwareengine_resources.NetworkPeering.deserialize, @@ -1474,7 +1570,7 @@ def list_network_peerings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_network_peerings" not in self._stubs: - self._stubs["list_network_peerings"] = self.grpc_channel.unary_unary( + self._stubs["list_network_peerings"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListNetworkPeerings", request_serializer=vmwareengine.ListNetworkPeeringsRequest.serialize, response_deserializer=vmwareengine.ListNetworkPeeringsResponse.deserialize, @@ -1503,7 +1599,7 @@ def create_network_peering( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_network_peering" not in self._stubs: - self._stubs["create_network_peering"] = self.grpc_channel.unary_unary( + self._stubs["create_network_peering"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateNetworkPeering", request_serializer=vmwareengine.CreateNetworkPeeringRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1532,7 +1628,7 @@ def delete_network_peering( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_network_peering" not in self._stubs: - self._stubs["delete_network_peering"] = self.grpc_channel.unary_unary( + self._stubs["delete_network_peering"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteNetworkPeering", request_serializer=vmwareengine.DeleteNetworkPeeringRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1561,7 +1657,7 @@ def update_network_peering( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_network_peering" not in self._stubs: - self._stubs["update_network_peering"] = self.grpc_channel.unary_unary( + self._stubs["update_network_peering"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateNetworkPeering", request_serializer=vmwareengine.UpdateNetworkPeeringRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1591,7 +1687,7 @@ def list_peering_routes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_peering_routes" not in self._stubs: - self._stubs["list_peering_routes"] = self.grpc_channel.unary_unary( + self._stubs["list_peering_routes"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListPeeringRoutes", request_serializer=vmwareengine.ListPeeringRoutesRequest.serialize, response_deserializer=vmwareengine.ListPeeringRoutesResponse.deserialize, @@ -1620,7 +1716,7 @@ def create_hcx_activation_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_hcx_activation_key" not in self._stubs: - self._stubs["create_hcx_activation_key"] = self.grpc_channel.unary_unary( + self._stubs["create_hcx_activation_key"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateHcxActivationKey", request_serializer=vmwareengine.CreateHcxActivationKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1649,7 +1745,7 @@ def list_hcx_activation_keys( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_hcx_activation_keys" not in self._stubs: - self._stubs["list_hcx_activation_keys"] = self.grpc_channel.unary_unary( + self._stubs["list_hcx_activation_keys"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListHcxActivationKeys", request_serializer=vmwareengine.ListHcxActivationKeysRequest.serialize, response_deserializer=vmwareengine.ListHcxActivationKeysResponse.deserialize, @@ -1678,7 +1774,7 @@ def get_hcx_activation_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_hcx_activation_key" not in self._stubs: - self._stubs["get_hcx_activation_key"] = self.grpc_channel.unary_unary( + self._stubs["get_hcx_activation_key"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetHcxActivationKey", request_serializer=vmwareengine.GetHcxActivationKeyRequest.serialize, response_deserializer=vmwareengine_resources.HcxActivationKey.deserialize, @@ -1706,7 +1802,7 @@ def get_network_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_network_policy" not in self._stubs: - self._stubs["get_network_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_network_policy"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetNetworkPolicy", request_serializer=vmwareengine.GetNetworkPolicyRequest.serialize, response_deserializer=vmwareengine_resources.NetworkPolicy.deserialize, @@ -1736,7 +1832,7 @@ def list_network_policies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_network_policies" not in self._stubs: - self._stubs["list_network_policies"] = self.grpc_channel.unary_unary( + self._stubs["list_network_policies"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListNetworkPolicies", request_serializer=vmwareengine.ListNetworkPoliciesRequest.serialize, response_deserializer=vmwareengine.ListNetworkPoliciesResponse.deserialize, @@ -1765,7 +1861,7 @@ def create_network_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_network_policy" not in self._stubs: - self._stubs["create_network_policy"] = self.grpc_channel.unary_unary( + self._stubs["create_network_policy"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateNetworkPolicy", request_serializer=vmwareengine.CreateNetworkPolicyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1803,7 +1899,7 @@ def update_network_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_network_policy" not in self._stubs: - self._stubs["update_network_policy"] = self.grpc_channel.unary_unary( + self._stubs["update_network_policy"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateNetworkPolicy", request_serializer=vmwareengine.UpdateNetworkPolicyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1831,7 +1927,7 @@ def delete_network_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_network_policy" not in self._stubs: - self._stubs["delete_network_policy"] = self.grpc_channel.unary_unary( + self._stubs["delete_network_policy"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteNetworkPolicy", request_serializer=vmwareengine.DeleteNetworkPolicyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1864,7 +1960,7 @@ def list_management_dns_zone_bindings( if "list_management_dns_zone_bindings" not in self._stubs: self._stubs[ "list_management_dns_zone_bindings" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListManagementDnsZoneBindings", request_serializer=vmwareengine.ListManagementDnsZoneBindingsRequest.serialize, response_deserializer=vmwareengine.ListManagementDnsZoneBindingsResponse.deserialize, @@ -1897,7 +1993,7 @@ def get_management_dns_zone_binding( if "get_management_dns_zone_binding" not in self._stubs: self._stubs[ "get_management_dns_zone_binding" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetManagementDnsZoneBinding", request_serializer=vmwareengine.GetManagementDnsZoneBindingRequest.serialize, response_deserializer=vmwareengine_resources.ManagementDnsZoneBinding.deserialize, @@ -1935,7 +2031,7 @@ def create_management_dns_zone_binding( if "create_management_dns_zone_binding" not in self._stubs: self._stubs[ "create_management_dns_zone_binding" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateManagementDnsZoneBinding", request_serializer=vmwareengine.CreateManagementDnsZoneBindingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1967,7 +2063,7 @@ def update_management_dns_zone_binding( if "update_management_dns_zone_binding" not in self._stubs: self._stubs[ "update_management_dns_zone_binding" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateManagementDnsZoneBinding", request_serializer=vmwareengine.UpdateManagementDnsZoneBindingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2001,7 +2097,7 @@ def delete_management_dns_zone_binding( if "delete_management_dns_zone_binding" not in self._stubs: self._stubs[ "delete_management_dns_zone_binding" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteManagementDnsZoneBinding", request_serializer=vmwareengine.DeleteManagementDnsZoneBindingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2033,7 +2129,7 @@ def repair_management_dns_zone_binding( if "repair_management_dns_zone_binding" not in self._stubs: self._stubs[ "repair_management_dns_zone_binding" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/RepairManagementDnsZoneBinding", request_serializer=vmwareengine.RepairManagementDnsZoneBindingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2062,7 +2158,9 @@ def create_vmware_engine_network( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_vmware_engine_network" not in self._stubs: - self._stubs["create_vmware_engine_network"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_vmware_engine_network" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateVmwareEngineNetwork", request_serializer=vmwareengine.CreateVmwareEngineNetworkRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2092,7 +2190,9 @@ def update_vmware_engine_network( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_vmware_engine_network" not in self._stubs: - self._stubs["update_vmware_engine_network"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_vmware_engine_network" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateVmwareEngineNetwork", request_serializer=vmwareengine.UpdateVmwareEngineNetworkRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2123,7 +2223,9 @@ def delete_vmware_engine_network( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_vmware_engine_network" not in self._stubs: - self._stubs["delete_vmware_engine_network"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_vmware_engine_network" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteVmwareEngineNetwork", request_serializer=vmwareengine.DeleteVmwareEngineNetworkRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2156,7 +2258,7 @@ def get_vmware_engine_network( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_vmware_engine_network" not in self._stubs: - self._stubs["get_vmware_engine_network"] = self.grpc_channel.unary_unary( + self._stubs["get_vmware_engine_network"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetVmwareEngineNetwork", request_serializer=vmwareengine.GetVmwareEngineNetworkRequest.serialize, response_deserializer=vmwareengine_resources.VmwareEngineNetwork.deserialize, @@ -2186,7 +2288,9 @@ def list_vmware_engine_networks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_vmware_engine_networks" not in self._stubs: - self._stubs["list_vmware_engine_networks"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_vmware_engine_networks" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListVmwareEngineNetworks", request_serializer=vmwareengine.ListVmwareEngineNetworksRequest.serialize, response_deserializer=vmwareengine.ListVmwareEngineNetworksResponse.deserialize, @@ -2215,7 +2319,7 @@ def create_private_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_private_connection" not in self._stubs: - self._stubs["create_private_connection"] = self.grpc_channel.unary_unary( + self._stubs["create_private_connection"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreatePrivateConnection", request_serializer=vmwareengine.CreatePrivateConnectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2246,7 +2350,7 @@ def get_private_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_private_connection" not in self._stubs: - self._stubs["get_private_connection"] = self.grpc_channel.unary_unary( + self._stubs["get_private_connection"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetPrivateConnection", request_serializer=vmwareengine.GetPrivateConnectionRequest.serialize, response_deserializer=vmwareengine_resources.PrivateConnection.deserialize, @@ -2276,7 +2380,7 @@ def list_private_connections( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_private_connections" not in self._stubs: - self._stubs["list_private_connections"] = self.grpc_channel.unary_unary( + self._stubs["list_private_connections"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListPrivateConnections", request_serializer=vmwareengine.ListPrivateConnectionsRequest.serialize, response_deserializer=vmwareengine.ListPrivateConnectionsResponse.deserialize, @@ -2306,7 +2410,7 @@ def update_private_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_private_connection" not in self._stubs: - self._stubs["update_private_connection"] = self.grpc_channel.unary_unary( + self._stubs["update_private_connection"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdatePrivateConnection", request_serializer=vmwareengine.UpdatePrivateConnectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2336,7 +2440,7 @@ def delete_private_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_private_connection" not in self._stubs: - self._stubs["delete_private_connection"] = self.grpc_channel.unary_unary( + self._stubs["delete_private_connection"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeletePrivateConnection", request_serializer=vmwareengine.DeletePrivateConnectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2369,7 +2473,7 @@ def list_private_connection_peering_routes( if "list_private_connection_peering_routes" not in self._stubs: self._stubs[ "list_private_connection_peering_routes" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListPrivateConnectionPeeringRoutes", request_serializer=vmwareengine.ListPrivateConnectionPeeringRoutesRequest.serialize, response_deserializer=vmwareengine.ListPrivateConnectionPeeringRoutesResponse.deserialize, @@ -2401,7 +2505,7 @@ def grant_dns_bind_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "grant_dns_bind_permission" not in self._stubs: - self._stubs["grant_dns_bind_permission"] = self.grpc_channel.unary_unary( + self._stubs["grant_dns_bind_permission"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GrantDnsBindPermission", request_serializer=vmwareengine.GrantDnsBindPermissionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2433,7 +2537,7 @@ def get_dns_bind_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_dns_bind_permission" not in self._stubs: - self._stubs["get_dns_bind_permission"] = self.grpc_channel.unary_unary( + self._stubs["get_dns_bind_permission"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetDnsBindPermission", request_serializer=vmwareengine.GetDnsBindPermissionRequest.serialize, response_deserializer=vmwareengine_resources.DnsBindPermission.deserialize, @@ -2465,7 +2569,9 @@ def revoke_dns_bind_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "revoke_dns_bind_permission" not in self._stubs: - self._stubs["revoke_dns_bind_permission"] = self.grpc_channel.unary_unary( + self._stubs[ + "revoke_dns_bind_permission" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/RevokeDnsBindPermission", request_serializer=vmwareengine.RevokeDnsBindPermissionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2473,7 +2579,7 @@ def revoke_dns_bind_permission( return self._stubs["revoke_dns_bind_permission"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -2485,7 +2591,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, @@ -2502,7 +2608,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, @@ -2521,7 +2627,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, @@ -2540,7 +2646,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, @@ -2557,7 +2663,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, @@ -2582,7 +2688,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, @@ -2608,7 +2714,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, @@ -2637,7 +2743,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-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/transports/grpc_asyncio.py b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/transports/grpc_asyncio.py index 96d05cf76b09..d5facf597d8c 100644 --- a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/transports/grpc_asyncio.py +++ b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/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.vmwareengine_v1.types import vmwareengine, vmwareengine_resources from .base import DEFAULT_CLIENT_INFO, VmwareEngineTransport from .grpc import VmwareEngineGrpcTransport +try: + from google.api_core import client_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.vmwareengine.v1.VmwareEngine", + "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.vmwareengine.v1.VmwareEngine", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VmwareEngineGrpcAsyncIOTransport(VmwareEngineTransport): """gRPC AsyncIO backend transport for VmwareEngine. @@ -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. @@ -286,7 +371,7 @@ def list_private_clouds( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_private_clouds" not in self._stubs: - self._stubs["list_private_clouds"] = self.grpc_channel.unary_unary( + self._stubs["list_private_clouds"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListPrivateClouds", request_serializer=vmwareengine.ListPrivateCloudsRequest.serialize, response_deserializer=vmwareengine.ListPrivateCloudsResponse.deserialize, @@ -315,7 +400,7 @@ def get_private_cloud( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_private_cloud" not in self._stubs: - self._stubs["get_private_cloud"] = self.grpc_channel.unary_unary( + self._stubs["get_private_cloud"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetPrivateCloud", request_serializer=vmwareengine.GetPrivateCloudRequest.serialize, response_deserializer=vmwareengine_resources.PrivateCloud.deserialize, @@ -349,7 +434,7 @@ def create_private_cloud( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_private_cloud" not in self._stubs: - self._stubs["create_private_cloud"] = self.grpc_channel.unary_unary( + self._stubs["create_private_cloud"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreatePrivateCloud", request_serializer=vmwareengine.CreatePrivateCloudRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -384,7 +469,7 @@ def update_private_cloud( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_private_cloud" not in self._stubs: - self._stubs["update_private_cloud"] = self.grpc_channel.unary_unary( + self._stubs["update_private_cloud"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdatePrivateCloud", request_serializer=vmwareengine.UpdatePrivateCloudRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -429,7 +514,7 @@ def delete_private_cloud( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_private_cloud" not in self._stubs: - self._stubs["delete_private_cloud"] = self.grpc_channel.unary_unary( + self._stubs["delete_private_cloud"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeletePrivateCloud", request_serializer=vmwareengine.DeletePrivateCloudRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -461,7 +546,7 @@ def undelete_private_cloud( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undelete_private_cloud" not in self._stubs: - self._stubs["undelete_private_cloud"] = self.grpc_channel.unary_unary( + self._stubs["undelete_private_cloud"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UndeletePrivateCloud", request_serializer=vmwareengine.UndeletePrivateCloudRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -489,7 +574,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.vmwareengine.v1.VmwareEngine/ListClusters", request_serializer=vmwareengine.ListClustersRequest.serialize, response_deserializer=vmwareengine.ListClustersResponse.deserialize, @@ -517,7 +602,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.vmwareengine.v1.VmwareEngine/GetCluster", request_serializer=vmwareengine.GetClusterRequest.serialize, response_deserializer=vmwareengine_resources.Cluster.deserialize, @@ -548,7 +633,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.vmwareengine.v1.VmwareEngine/CreateCluster", request_serializer=vmwareengine.CreateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -582,7 +667,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.vmwareengine.v1.VmwareEngine/UpdateCluster", request_serializer=vmwareengine.UpdateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -613,7 +698,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.vmwareengine.v1.VmwareEngine/DeleteCluster", request_serializer=vmwareengine.DeleteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -641,7 +726,7 @@ def list_nodes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_nodes" not in self._stubs: - self._stubs["list_nodes"] = self.grpc_channel.unary_unary( + self._stubs["list_nodes"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListNodes", request_serializer=vmwareengine.ListNodesRequest.serialize, response_deserializer=vmwareengine.ListNodesResponse.deserialize, @@ -669,7 +754,7 @@ def get_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_node" not in self._stubs: - self._stubs["get_node"] = self.grpc_channel.unary_unary( + self._stubs["get_node"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetNode", request_serializer=vmwareengine.GetNodeRequest.serialize, response_deserializer=vmwareengine_resources.Node.deserialize, @@ -699,7 +784,7 @@ def list_external_addresses( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_external_addresses" not in self._stubs: - self._stubs["list_external_addresses"] = self.grpc_channel.unary_unary( + self._stubs["list_external_addresses"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListExternalAddresses", request_serializer=vmwareengine.ListExternalAddressesRequest.serialize, response_deserializer=vmwareengine.ListExternalAddressesResponse.deserialize, @@ -733,7 +818,7 @@ def fetch_network_policy_external_addresses( if "fetch_network_policy_external_addresses" not in self._stubs: self._stubs[ "fetch_network_policy_external_addresses" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/FetchNetworkPolicyExternalAddresses", request_serializer=vmwareengine.FetchNetworkPolicyExternalAddressesRequest.serialize, response_deserializer=vmwareengine.FetchNetworkPolicyExternalAddressesResponse.deserialize, @@ -762,7 +847,7 @@ def get_external_address( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_external_address" not in self._stubs: - self._stubs["get_external_address"] = self.grpc_channel.unary_unary( + self._stubs["get_external_address"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetExternalAddress", request_serializer=vmwareengine.GetExternalAddressRequest.serialize, response_deserializer=vmwareengine_resources.ExternalAddress.deserialize, @@ -793,7 +878,7 @@ def create_external_address( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_external_address" not in self._stubs: - self._stubs["create_external_address"] = self.grpc_channel.unary_unary( + self._stubs["create_external_address"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateExternalAddress", request_serializer=vmwareengine.CreateExternalAddressRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -827,7 +912,7 @@ def update_external_address( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_external_address" not in self._stubs: - self._stubs["update_external_address"] = self.grpc_channel.unary_unary( + self._stubs["update_external_address"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateExternalAddress", request_serializer=vmwareengine.UpdateExternalAddressRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -858,7 +943,7 @@ def delete_external_address( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_external_address" not in self._stubs: - self._stubs["delete_external_address"] = self.grpc_channel.unary_unary( + self._stubs["delete_external_address"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteExternalAddress", request_serializer=vmwareengine.DeleteExternalAddressRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -886,7 +971,7 @@ def list_subnets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_subnets" not in self._stubs: - self._stubs["list_subnets"] = self.grpc_channel.unary_unary( + self._stubs["list_subnets"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListSubnets", request_serializer=vmwareengine.ListSubnetsRequest.serialize, response_deserializer=vmwareengine.ListSubnetsResponse.deserialize, @@ -914,7 +999,7 @@ def get_subnet( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_subnet" not in self._stubs: - self._stubs["get_subnet"] = self.grpc_channel.unary_unary( + self._stubs["get_subnet"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetSubnet", request_serializer=vmwareengine.GetSubnetRequest.serialize, response_deserializer=vmwareengine_resources.Subnet.deserialize, @@ -947,7 +1032,7 @@ def update_subnet( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_subnet" not in self._stubs: - self._stubs["update_subnet"] = self.grpc_channel.unary_unary( + self._stubs["update_subnet"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateSubnet", request_serializer=vmwareengine.UpdateSubnetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -977,7 +1062,9 @@ def list_external_access_rules( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_external_access_rules" not in self._stubs: - self._stubs["list_external_access_rules"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_external_access_rules" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListExternalAccessRules", request_serializer=vmwareengine.ListExternalAccessRulesRequest.serialize, response_deserializer=vmwareengine.ListExternalAccessRulesResponse.deserialize, @@ -1006,7 +1093,7 @@ def get_external_access_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_external_access_rule" not in self._stubs: - self._stubs["get_external_access_rule"] = self.grpc_channel.unary_unary( + self._stubs["get_external_access_rule"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetExternalAccessRule", request_serializer=vmwareengine.GetExternalAccessRuleRequest.serialize, response_deserializer=vmwareengine_resources.ExternalAccessRule.deserialize, @@ -1036,7 +1123,9 @@ def create_external_access_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_external_access_rule" not in self._stubs: - self._stubs["create_external_access_rule"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_external_access_rule" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateExternalAccessRule", request_serializer=vmwareengine.CreateExternalAccessRuleRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1066,7 +1155,9 @@ def update_external_access_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_external_access_rule" not in self._stubs: - self._stubs["update_external_access_rule"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_external_access_rule" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateExternalAccessRule", request_serializer=vmwareengine.UpdateExternalAccessRuleRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1095,7 +1186,9 @@ def delete_external_access_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_external_access_rule" not in self._stubs: - self._stubs["delete_external_access_rule"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_external_access_rule" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteExternalAccessRule", request_serializer=vmwareengine.DeleteExternalAccessRuleRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1125,7 +1218,7 @@ def list_logging_servers( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_logging_servers" not in self._stubs: - self._stubs["list_logging_servers"] = self.grpc_channel.unary_unary( + self._stubs["list_logging_servers"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListLoggingServers", request_serializer=vmwareengine.ListLoggingServersRequest.serialize, response_deserializer=vmwareengine.ListLoggingServersResponse.deserialize, @@ -1154,7 +1247,7 @@ def get_logging_server( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_logging_server" not in self._stubs: - self._stubs["get_logging_server"] = self.grpc_channel.unary_unary( + self._stubs["get_logging_server"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetLoggingServer", request_serializer=vmwareengine.GetLoggingServerRequest.serialize, response_deserializer=vmwareengine_resources.LoggingServer.deserialize, @@ -1183,7 +1276,7 @@ def create_logging_server( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_logging_server" not in self._stubs: - self._stubs["create_logging_server"] = self.grpc_channel.unary_unary( + self._stubs["create_logging_server"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateLoggingServer", request_serializer=vmwareengine.CreateLoggingServerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1212,7 +1305,7 @@ def update_logging_server( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_logging_server" not in self._stubs: - self._stubs["update_logging_server"] = self.grpc_channel.unary_unary( + self._stubs["update_logging_server"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateLoggingServer", request_serializer=vmwareengine.UpdateLoggingServerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1240,7 +1333,7 @@ def delete_logging_server( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_logging_server" not in self._stubs: - self._stubs["delete_logging_server"] = self.grpc_channel.unary_unary( + self._stubs["delete_logging_server"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteLoggingServer", request_serializer=vmwareengine.DeleteLoggingServerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1269,7 +1362,7 @@ def list_node_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_node_types" not in self._stubs: - self._stubs["list_node_types"] = self.grpc_channel.unary_unary( + self._stubs["list_node_types"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListNodeTypes", request_serializer=vmwareengine.ListNodeTypesRequest.serialize, response_deserializer=vmwareengine.ListNodeTypesResponse.deserialize, @@ -1297,7 +1390,7 @@ def get_node_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_node_type" not in self._stubs: - self._stubs["get_node_type"] = self.grpc_channel.unary_unary( + self._stubs["get_node_type"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetNodeType", request_serializer=vmwareengine.GetNodeTypeRequest.serialize, response_deserializer=vmwareengine_resources.NodeType.deserialize, @@ -1326,7 +1419,7 @@ def show_nsx_credentials( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "show_nsx_credentials" not in self._stubs: - self._stubs["show_nsx_credentials"] = self.grpc_channel.unary_unary( + self._stubs["show_nsx_credentials"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ShowNsxCredentials", request_serializer=vmwareengine.ShowNsxCredentialsRequest.serialize, response_deserializer=vmwareengine_resources.Credentials.deserialize, @@ -1355,7 +1448,7 @@ def show_vcenter_credentials( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "show_vcenter_credentials" not in self._stubs: - self._stubs["show_vcenter_credentials"] = self.grpc_channel.unary_unary( + self._stubs["show_vcenter_credentials"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ShowVcenterCredentials", request_serializer=vmwareengine.ShowVcenterCredentialsRequest.serialize, response_deserializer=vmwareengine_resources.Credentials.deserialize, @@ -1383,7 +1476,7 @@ def reset_nsx_credentials( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reset_nsx_credentials" not in self._stubs: - self._stubs["reset_nsx_credentials"] = self.grpc_channel.unary_unary( + self._stubs["reset_nsx_credentials"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ResetNsxCredentials", request_serializer=vmwareengine.ResetNsxCredentialsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1412,7 +1505,7 @@ def reset_vcenter_credentials( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reset_vcenter_credentials" not in self._stubs: - self._stubs["reset_vcenter_credentials"] = self.grpc_channel.unary_unary( + self._stubs["reset_vcenter_credentials"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ResetVcenterCredentials", request_serializer=vmwareengine.ResetVcenterCredentialsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1441,7 +1534,7 @@ def get_dns_forwarding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_dns_forwarding" not in self._stubs: - self._stubs["get_dns_forwarding"] = self.grpc_channel.unary_unary( + self._stubs["get_dns_forwarding"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetDnsForwarding", request_serializer=vmwareengine.GetDnsForwardingRequest.serialize, response_deserializer=vmwareengine_resources.DnsForwarding.deserialize, @@ -1471,7 +1564,7 @@ def update_dns_forwarding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_dns_forwarding" not in self._stubs: - self._stubs["update_dns_forwarding"] = self.grpc_channel.unary_unary( + self._stubs["update_dns_forwarding"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateDnsForwarding", request_serializer=vmwareengine.UpdateDnsForwardingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1504,7 +1597,7 @@ def get_network_peering( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_network_peering" not in self._stubs: - self._stubs["get_network_peering"] = self.grpc_channel.unary_unary( + self._stubs["get_network_peering"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetNetworkPeering", request_serializer=vmwareengine.GetNetworkPeeringRequest.serialize, response_deserializer=vmwareengine_resources.NetworkPeering.deserialize, @@ -1535,7 +1628,7 @@ def list_network_peerings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_network_peerings" not in self._stubs: - self._stubs["list_network_peerings"] = self.grpc_channel.unary_unary( + self._stubs["list_network_peerings"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListNetworkPeerings", request_serializer=vmwareengine.ListNetworkPeeringsRequest.serialize, response_deserializer=vmwareengine.ListNetworkPeeringsResponse.deserialize, @@ -1566,7 +1659,7 @@ def create_network_peering( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_network_peering" not in self._stubs: - self._stubs["create_network_peering"] = self.grpc_channel.unary_unary( + self._stubs["create_network_peering"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateNetworkPeering", request_serializer=vmwareengine.CreateNetworkPeeringRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1597,7 +1690,7 @@ def delete_network_peering( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_network_peering" not in self._stubs: - self._stubs["delete_network_peering"] = self.grpc_channel.unary_unary( + self._stubs["delete_network_peering"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteNetworkPeering", request_serializer=vmwareengine.DeleteNetworkPeeringRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1628,7 +1721,7 @@ def update_network_peering( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_network_peering" not in self._stubs: - self._stubs["update_network_peering"] = self.grpc_channel.unary_unary( + self._stubs["update_network_peering"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateNetworkPeering", request_serializer=vmwareengine.UpdateNetworkPeeringRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1659,7 +1752,7 @@ def list_peering_routes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_peering_routes" not in self._stubs: - self._stubs["list_peering_routes"] = self.grpc_channel.unary_unary( + self._stubs["list_peering_routes"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListPeeringRoutes", request_serializer=vmwareengine.ListPeeringRoutesRequest.serialize, response_deserializer=vmwareengine.ListPeeringRoutesResponse.deserialize, @@ -1689,7 +1782,7 @@ def create_hcx_activation_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_hcx_activation_key" not in self._stubs: - self._stubs["create_hcx_activation_key"] = self.grpc_channel.unary_unary( + self._stubs["create_hcx_activation_key"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateHcxActivationKey", request_serializer=vmwareengine.CreateHcxActivationKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1718,7 +1811,7 @@ def list_hcx_activation_keys( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_hcx_activation_keys" not in self._stubs: - self._stubs["list_hcx_activation_keys"] = self.grpc_channel.unary_unary( + self._stubs["list_hcx_activation_keys"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListHcxActivationKeys", request_serializer=vmwareengine.ListHcxActivationKeysRequest.serialize, response_deserializer=vmwareengine.ListHcxActivationKeysResponse.deserialize, @@ -1747,7 +1840,7 @@ def get_hcx_activation_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_hcx_activation_key" not in self._stubs: - self._stubs["get_hcx_activation_key"] = self.grpc_channel.unary_unary( + self._stubs["get_hcx_activation_key"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetHcxActivationKey", request_serializer=vmwareengine.GetHcxActivationKeyRequest.serialize, response_deserializer=vmwareengine_resources.HcxActivationKey.deserialize, @@ -1776,7 +1869,7 @@ def get_network_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_network_policy" not in self._stubs: - self._stubs["get_network_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_network_policy"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetNetworkPolicy", request_serializer=vmwareengine.GetNetworkPolicyRequest.serialize, response_deserializer=vmwareengine_resources.NetworkPolicy.deserialize, @@ -1806,7 +1899,7 @@ def list_network_policies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_network_policies" not in self._stubs: - self._stubs["list_network_policies"] = self.grpc_channel.unary_unary( + self._stubs["list_network_policies"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListNetworkPolicies", request_serializer=vmwareengine.ListNetworkPoliciesRequest.serialize, response_deserializer=vmwareengine.ListNetworkPoliciesResponse.deserialize, @@ -1837,7 +1930,7 @@ def create_network_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_network_policy" not in self._stubs: - self._stubs["create_network_policy"] = self.grpc_channel.unary_unary( + self._stubs["create_network_policy"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateNetworkPolicy", request_serializer=vmwareengine.CreateNetworkPolicyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1877,7 +1970,7 @@ def update_network_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_network_policy" not in self._stubs: - self._stubs["update_network_policy"] = self.grpc_channel.unary_unary( + self._stubs["update_network_policy"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateNetworkPolicy", request_serializer=vmwareengine.UpdateNetworkPolicyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1907,7 +2000,7 @@ def delete_network_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_network_policy" not in self._stubs: - self._stubs["delete_network_policy"] = self.grpc_channel.unary_unary( + self._stubs["delete_network_policy"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteNetworkPolicy", request_serializer=vmwareengine.DeleteNetworkPolicyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1940,7 +2033,7 @@ def list_management_dns_zone_bindings( if "list_management_dns_zone_bindings" not in self._stubs: self._stubs[ "list_management_dns_zone_bindings" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListManagementDnsZoneBindings", request_serializer=vmwareengine.ListManagementDnsZoneBindingsRequest.serialize, response_deserializer=vmwareengine.ListManagementDnsZoneBindingsResponse.deserialize, @@ -1973,7 +2066,7 @@ def get_management_dns_zone_binding( if "get_management_dns_zone_binding" not in self._stubs: self._stubs[ "get_management_dns_zone_binding" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetManagementDnsZoneBinding", request_serializer=vmwareengine.GetManagementDnsZoneBindingRequest.serialize, response_deserializer=vmwareengine_resources.ManagementDnsZoneBinding.deserialize, @@ -2012,7 +2105,7 @@ def create_management_dns_zone_binding( if "create_management_dns_zone_binding" not in self._stubs: self._stubs[ "create_management_dns_zone_binding" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateManagementDnsZoneBinding", request_serializer=vmwareengine.CreateManagementDnsZoneBindingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2045,7 +2138,7 @@ def update_management_dns_zone_binding( if "update_management_dns_zone_binding" not in self._stubs: self._stubs[ "update_management_dns_zone_binding" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateManagementDnsZoneBinding", request_serializer=vmwareengine.UpdateManagementDnsZoneBindingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2080,7 +2173,7 @@ def delete_management_dns_zone_binding( if "delete_management_dns_zone_binding" not in self._stubs: self._stubs[ "delete_management_dns_zone_binding" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteManagementDnsZoneBinding", request_serializer=vmwareengine.DeleteManagementDnsZoneBindingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2113,7 +2206,7 @@ def repair_management_dns_zone_binding( if "repair_management_dns_zone_binding" not in self._stubs: self._stubs[ "repair_management_dns_zone_binding" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/RepairManagementDnsZoneBinding", request_serializer=vmwareengine.RepairManagementDnsZoneBindingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2143,7 +2236,9 @@ def create_vmware_engine_network( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_vmware_engine_network" not in self._stubs: - self._stubs["create_vmware_engine_network"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_vmware_engine_network" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateVmwareEngineNetwork", request_serializer=vmwareengine.CreateVmwareEngineNetworkRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2174,7 +2269,9 @@ def update_vmware_engine_network( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_vmware_engine_network" not in self._stubs: - self._stubs["update_vmware_engine_network"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_vmware_engine_network" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateVmwareEngineNetwork", request_serializer=vmwareengine.UpdateVmwareEngineNetworkRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2206,7 +2303,9 @@ def delete_vmware_engine_network( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_vmware_engine_network" not in self._stubs: - self._stubs["delete_vmware_engine_network"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_vmware_engine_network" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteVmwareEngineNetwork", request_serializer=vmwareengine.DeleteVmwareEngineNetworkRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2239,7 +2338,7 @@ def get_vmware_engine_network( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_vmware_engine_network" not in self._stubs: - self._stubs["get_vmware_engine_network"] = self.grpc_channel.unary_unary( + self._stubs["get_vmware_engine_network"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetVmwareEngineNetwork", request_serializer=vmwareengine.GetVmwareEngineNetworkRequest.serialize, response_deserializer=vmwareengine_resources.VmwareEngineNetwork.deserialize, @@ -2269,7 +2368,9 @@ def list_vmware_engine_networks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_vmware_engine_networks" not in self._stubs: - self._stubs["list_vmware_engine_networks"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_vmware_engine_networks" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListVmwareEngineNetworks", request_serializer=vmwareengine.ListVmwareEngineNetworksRequest.serialize, response_deserializer=vmwareengine.ListVmwareEngineNetworksResponse.deserialize, @@ -2299,7 +2400,7 @@ def create_private_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_private_connection" not in self._stubs: - self._stubs["create_private_connection"] = self.grpc_channel.unary_unary( + self._stubs["create_private_connection"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreatePrivateConnection", request_serializer=vmwareengine.CreatePrivateConnectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2330,7 +2431,7 @@ def get_private_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_private_connection" not in self._stubs: - self._stubs["get_private_connection"] = self.grpc_channel.unary_unary( + self._stubs["get_private_connection"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetPrivateConnection", request_serializer=vmwareengine.GetPrivateConnectionRequest.serialize, response_deserializer=vmwareengine_resources.PrivateConnection.deserialize, @@ -2360,7 +2461,7 @@ def list_private_connections( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_private_connections" not in self._stubs: - self._stubs["list_private_connections"] = self.grpc_channel.unary_unary( + self._stubs["list_private_connections"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListPrivateConnections", request_serializer=vmwareengine.ListPrivateConnectionsRequest.serialize, response_deserializer=vmwareengine.ListPrivateConnectionsResponse.deserialize, @@ -2391,7 +2492,7 @@ def update_private_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_private_connection" not in self._stubs: - self._stubs["update_private_connection"] = self.grpc_channel.unary_unary( + self._stubs["update_private_connection"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdatePrivateConnection", request_serializer=vmwareengine.UpdatePrivateConnectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2422,7 +2523,7 @@ def delete_private_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_private_connection" not in self._stubs: - self._stubs["delete_private_connection"] = self.grpc_channel.unary_unary( + self._stubs["delete_private_connection"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeletePrivateConnection", request_serializer=vmwareengine.DeletePrivateConnectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2455,7 +2556,7 @@ def list_private_connection_peering_routes( if "list_private_connection_peering_routes" not in self._stubs: self._stubs[ "list_private_connection_peering_routes" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListPrivateConnectionPeeringRoutes", request_serializer=vmwareengine.ListPrivateConnectionPeeringRoutesRequest.serialize, response_deserializer=vmwareengine.ListPrivateConnectionPeeringRoutesResponse.deserialize, @@ -2488,7 +2589,7 @@ def grant_dns_bind_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "grant_dns_bind_permission" not in self._stubs: - self._stubs["grant_dns_bind_permission"] = self.grpc_channel.unary_unary( + self._stubs["grant_dns_bind_permission"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GrantDnsBindPermission", request_serializer=vmwareengine.GrantDnsBindPermissionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2520,7 +2621,7 @@ def get_dns_bind_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_dns_bind_permission" not in self._stubs: - self._stubs["get_dns_bind_permission"] = self.grpc_channel.unary_unary( + self._stubs["get_dns_bind_permission"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetDnsBindPermission", request_serializer=vmwareengine.GetDnsBindPermissionRequest.serialize, response_deserializer=vmwareengine_resources.DnsBindPermission.deserialize, @@ -2553,7 +2654,9 @@ def revoke_dns_bind_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "revoke_dns_bind_permission" not in self._stubs: - self._stubs["revoke_dns_bind_permission"] = self.grpc_channel.unary_unary( + self._stubs[ + "revoke_dns_bind_permission" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/RevokeDnsBindPermission", request_serializer=vmwareengine.RevokeDnsBindPermissionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -3287,7 +3390,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: @@ -3303,7 +3406,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, @@ -3320,7 +3423,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, @@ -3339,7 +3442,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, @@ -3358,7 +3461,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, @@ -3375,7 +3478,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, @@ -3400,7 +3503,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, @@ -3426,7 +3529,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, @@ -3455,7 +3558,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-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/transports/rest.py b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/transports/rest.py index 838825d6ae40..92229beb1391 100644 --- a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/transports/rest.py +++ b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/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, @@ -665,8 +673,10 @@ def post_update_vmware_engine_network(self, response): def pre_create_cluster( self, request: vmwareengine.CreateClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.CreateClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.CreateClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_cluster Override in a subclass to manipulate the request or metadata @@ -688,8 +698,11 @@ def post_create_cluster( def pre_create_external_access_rule( self, request: vmwareengine.CreateExternalAccessRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.CreateExternalAccessRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.CreateExternalAccessRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_external_access_rule Override in a subclass to manipulate the request or metadata @@ -711,8 +724,11 @@ def post_create_external_access_rule( def pre_create_external_address( self, request: vmwareengine.CreateExternalAddressRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.CreateExternalAddressRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.CreateExternalAddressRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_external_address Override in a subclass to manipulate the request or metadata @@ -734,8 +750,11 @@ def post_create_external_address( def pre_create_hcx_activation_key( self, request: vmwareengine.CreateHcxActivationKeyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.CreateHcxActivationKeyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.CreateHcxActivationKeyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_hcx_activation_key Override in a subclass to manipulate the request or metadata @@ -757,8 +776,10 @@ def post_create_hcx_activation_key( def pre_create_logging_server( self, request: vmwareengine.CreateLoggingServerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.CreateLoggingServerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.CreateLoggingServerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_logging_server Override in a subclass to manipulate the request or metadata @@ -780,9 +801,10 @@ def post_create_logging_server( def pre_create_management_dns_zone_binding( self, request: vmwareengine.CreateManagementDnsZoneBindingRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - vmwareengine.CreateManagementDnsZoneBindingRequest, Sequence[Tuple[str, str]] + vmwareengine.CreateManagementDnsZoneBindingRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_management_dns_zone_binding @@ -805,8 +827,11 @@ def post_create_management_dns_zone_binding( def pre_create_network_peering( self, request: vmwareengine.CreateNetworkPeeringRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.CreateNetworkPeeringRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.CreateNetworkPeeringRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_network_peering Override in a subclass to manipulate the request or metadata @@ -828,8 +853,10 @@ def post_create_network_peering( def pre_create_network_policy( self, request: vmwareengine.CreateNetworkPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.CreateNetworkPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.CreateNetworkPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_network_policy Override in a subclass to manipulate the request or metadata @@ -851,8 +878,10 @@ def post_create_network_policy( def pre_create_private_cloud( self, request: vmwareengine.CreatePrivateCloudRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.CreatePrivateCloudRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.CreatePrivateCloudRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_private_cloud Override in a subclass to manipulate the request or metadata @@ -874,8 +903,11 @@ def post_create_private_cloud( def pre_create_private_connection( self, request: vmwareengine.CreatePrivateConnectionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.CreatePrivateConnectionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.CreatePrivateConnectionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_private_connection Override in a subclass to manipulate the request or metadata @@ -897,9 +929,10 @@ def post_create_private_connection( def pre_create_vmware_engine_network( self, request: vmwareengine.CreateVmwareEngineNetworkRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - vmwareengine.CreateVmwareEngineNetworkRequest, Sequence[Tuple[str, str]] + vmwareengine.CreateVmwareEngineNetworkRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_vmware_engine_network @@ -922,8 +955,10 @@ def post_create_vmware_engine_network( def pre_delete_cluster( self, request: vmwareengine.DeleteClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.DeleteClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.DeleteClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_cluster Override in a subclass to manipulate the request or metadata @@ -945,8 +980,11 @@ def post_delete_cluster( def pre_delete_external_access_rule( self, request: vmwareengine.DeleteExternalAccessRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.DeleteExternalAccessRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.DeleteExternalAccessRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_external_access_rule Override in a subclass to manipulate the request or metadata @@ -968,8 +1006,11 @@ def post_delete_external_access_rule( def pre_delete_external_address( self, request: vmwareengine.DeleteExternalAddressRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.DeleteExternalAddressRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.DeleteExternalAddressRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_external_address Override in a subclass to manipulate the request or metadata @@ -991,8 +1032,10 @@ def post_delete_external_address( def pre_delete_logging_server( self, request: vmwareengine.DeleteLoggingServerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.DeleteLoggingServerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.DeleteLoggingServerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_logging_server Override in a subclass to manipulate the request or metadata @@ -1014,9 +1057,10 @@ def post_delete_logging_server( def pre_delete_management_dns_zone_binding( self, request: vmwareengine.DeleteManagementDnsZoneBindingRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - vmwareengine.DeleteManagementDnsZoneBindingRequest, Sequence[Tuple[str, str]] + vmwareengine.DeleteManagementDnsZoneBindingRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_management_dns_zone_binding @@ -1039,8 +1083,11 @@ def post_delete_management_dns_zone_binding( def pre_delete_network_peering( self, request: vmwareengine.DeleteNetworkPeeringRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.DeleteNetworkPeeringRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.DeleteNetworkPeeringRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_network_peering Override in a subclass to manipulate the request or metadata @@ -1062,8 +1109,10 @@ def post_delete_network_peering( def pre_delete_network_policy( self, request: vmwareengine.DeleteNetworkPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.DeleteNetworkPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.DeleteNetworkPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_network_policy Override in a subclass to manipulate the request or metadata @@ -1085,8 +1134,10 @@ def post_delete_network_policy( def pre_delete_private_cloud( self, request: vmwareengine.DeletePrivateCloudRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.DeletePrivateCloudRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.DeletePrivateCloudRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_private_cloud Override in a subclass to manipulate the request or metadata @@ -1108,8 +1159,11 @@ def post_delete_private_cloud( def pre_delete_private_connection( self, request: vmwareengine.DeletePrivateConnectionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.DeletePrivateConnectionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.DeletePrivateConnectionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_private_connection Override in a subclass to manipulate the request or metadata @@ -1131,9 +1185,10 @@ def post_delete_private_connection( def pre_delete_vmware_engine_network( self, request: vmwareengine.DeleteVmwareEngineNetworkRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - vmwareengine.DeleteVmwareEngineNetworkRequest, Sequence[Tuple[str, str]] + vmwareengine.DeleteVmwareEngineNetworkRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_vmware_engine_network @@ -1156,10 +1211,10 @@ def post_delete_vmware_engine_network( def pre_fetch_network_policy_external_addresses( self, request: vmwareengine.FetchNetworkPolicyExternalAddressesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ vmwareengine.FetchNetworkPolicyExternalAddressesRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for fetch_network_policy_external_addresses @@ -1182,8 +1237,8 @@ def post_fetch_network_policy_external_addresses( def pre_get_cluster( self, request: vmwareengine.GetClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vmwareengine.GetClusterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_cluster Override in a subclass to manipulate the request or metadata @@ -1205,8 +1260,11 @@ def post_get_cluster( def pre_get_dns_bind_permission( self, request: vmwareengine.GetDnsBindPermissionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetDnsBindPermissionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GetDnsBindPermissionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_dns_bind_permission Override in a subclass to manipulate the request or metadata @@ -1228,8 +1286,10 @@ def post_get_dns_bind_permission( def pre_get_dns_forwarding( self, request: vmwareengine.GetDnsForwardingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetDnsForwardingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GetDnsForwardingRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_dns_forwarding Override in a subclass to manipulate the request or metadata @@ -1251,8 +1311,11 @@ def post_get_dns_forwarding( def pre_get_external_access_rule( self, request: vmwareengine.GetExternalAccessRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetExternalAccessRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GetExternalAccessRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_external_access_rule Override in a subclass to manipulate the request or metadata @@ -1274,8 +1337,10 @@ def post_get_external_access_rule( def pre_get_external_address( self, request: vmwareengine.GetExternalAddressRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetExternalAddressRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GetExternalAddressRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_external_address Override in a subclass to manipulate the request or metadata @@ -1297,8 +1362,10 @@ def post_get_external_address( def pre_get_hcx_activation_key( self, request: vmwareengine.GetHcxActivationKeyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetHcxActivationKeyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GetHcxActivationKeyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_hcx_activation_key Override in a subclass to manipulate the request or metadata @@ -1320,8 +1387,10 @@ def post_get_hcx_activation_key( def pre_get_logging_server( self, request: vmwareengine.GetLoggingServerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetLoggingServerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GetLoggingServerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_logging_server Override in a subclass to manipulate the request or metadata @@ -1343,9 +1412,10 @@ def post_get_logging_server( def pre_get_management_dns_zone_binding( self, request: vmwareengine.GetManagementDnsZoneBindingRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - vmwareengine.GetManagementDnsZoneBindingRequest, Sequence[Tuple[str, str]] + vmwareengine.GetManagementDnsZoneBindingRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_management_dns_zone_binding @@ -1368,8 +1438,10 @@ def post_get_management_dns_zone_binding( def pre_get_network_peering( self, request: vmwareengine.GetNetworkPeeringRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetNetworkPeeringRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GetNetworkPeeringRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_network_peering Override in a subclass to manipulate the request or metadata @@ -1391,8 +1463,10 @@ def post_get_network_peering( def pre_get_network_policy( self, request: vmwareengine.GetNetworkPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetNetworkPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GetNetworkPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_network_policy Override in a subclass to manipulate the request or metadata @@ -1412,8 +1486,10 @@ def post_get_network_policy( return response def pre_get_node( - self, request: vmwareengine.GetNodeRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[vmwareengine.GetNodeRequest, Sequence[Tuple[str, str]]]: + self, + request: vmwareengine.GetNodeRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vmwareengine.GetNodeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_node Override in a subclass to manipulate the request or metadata @@ -1435,8 +1511,10 @@ def post_get_node( def pre_get_node_type( self, request: vmwareengine.GetNodeTypeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetNodeTypeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GetNodeTypeRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_node_type Override in a subclass to manipulate the request or metadata @@ -1458,8 +1536,10 @@ def post_get_node_type( def pre_get_private_cloud( self, request: vmwareengine.GetPrivateCloudRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetPrivateCloudRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GetPrivateCloudRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_private_cloud Override in a subclass to manipulate the request or metadata @@ -1481,8 +1561,11 @@ def post_get_private_cloud( def pre_get_private_connection( self, request: vmwareengine.GetPrivateConnectionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetPrivateConnectionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GetPrivateConnectionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_private_connection Override in a subclass to manipulate the request or metadata @@ -1504,8 +1587,8 @@ def post_get_private_connection( def pre_get_subnet( self, request: vmwareengine.GetSubnetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetSubnetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vmwareengine.GetSubnetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_subnet Override in a subclass to manipulate the request or metadata @@ -1527,8 +1610,11 @@ def post_get_subnet( def pre_get_vmware_engine_network( self, request: vmwareengine.GetVmwareEngineNetworkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetVmwareEngineNetworkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GetVmwareEngineNetworkRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_vmware_engine_network Override in a subclass to manipulate the request or metadata @@ -1550,8 +1636,11 @@ def post_get_vmware_engine_network( def pre_grant_dns_bind_permission( self, request: vmwareengine.GrantDnsBindPermissionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GrantDnsBindPermissionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GrantDnsBindPermissionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for grant_dns_bind_permission Override in a subclass to manipulate the request or metadata @@ -1573,8 +1662,10 @@ def post_grant_dns_bind_permission( def pre_list_clusters( self, request: vmwareengine.ListClustersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListClustersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListClustersRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_clusters Override in a subclass to manipulate the request or metadata @@ -1596,8 +1687,11 @@ def post_list_clusters( def pre_list_external_access_rules( self, request: vmwareengine.ListExternalAccessRulesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListExternalAccessRulesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListExternalAccessRulesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_external_access_rules Override in a subclass to manipulate the request or metadata @@ -1619,8 +1713,11 @@ def post_list_external_access_rules( def pre_list_external_addresses( self, request: vmwareengine.ListExternalAddressesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListExternalAddressesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListExternalAddressesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_external_addresses Override in a subclass to manipulate the request or metadata @@ -1642,8 +1739,11 @@ def post_list_external_addresses( def pre_list_hcx_activation_keys( self, request: vmwareengine.ListHcxActivationKeysRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListHcxActivationKeysRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListHcxActivationKeysRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_hcx_activation_keys Override in a subclass to manipulate the request or metadata @@ -1665,8 +1765,10 @@ def post_list_hcx_activation_keys( def pre_list_logging_servers( self, request: vmwareengine.ListLoggingServersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListLoggingServersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListLoggingServersRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_logging_servers Override in a subclass to manipulate the request or metadata @@ -1688,9 +1790,10 @@ def post_list_logging_servers( def pre_list_management_dns_zone_bindings( self, request: vmwareengine.ListManagementDnsZoneBindingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - vmwareengine.ListManagementDnsZoneBindingsRequest, Sequence[Tuple[str, str]] + vmwareengine.ListManagementDnsZoneBindingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_management_dns_zone_bindings @@ -1713,8 +1816,10 @@ def post_list_management_dns_zone_bindings( def pre_list_network_peerings( self, request: vmwareengine.ListNetworkPeeringsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListNetworkPeeringsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListNetworkPeeringsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_network_peerings Override in a subclass to manipulate the request or metadata @@ -1736,8 +1841,10 @@ def post_list_network_peerings( def pre_list_network_policies( self, request: vmwareengine.ListNetworkPoliciesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListNetworkPoliciesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListNetworkPoliciesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_network_policies Override in a subclass to manipulate the request or metadata @@ -1759,8 +1866,8 @@ def post_list_network_policies( def pre_list_nodes( self, request: vmwareengine.ListNodesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListNodesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vmwareengine.ListNodesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_nodes Override in a subclass to manipulate the request or metadata @@ -1782,8 +1889,10 @@ def post_list_nodes( def pre_list_node_types( self, request: vmwareengine.ListNodeTypesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListNodeTypesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListNodeTypesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_node_types Override in a subclass to manipulate the request or metadata @@ -1805,8 +1914,10 @@ def post_list_node_types( def pre_list_peering_routes( self, request: vmwareengine.ListPeeringRoutesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListPeeringRoutesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListPeeringRoutesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_peering_routes Override in a subclass to manipulate the request or metadata @@ -1828,8 +1939,10 @@ def post_list_peering_routes( def pre_list_private_clouds( self, request: vmwareengine.ListPrivateCloudsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListPrivateCloudsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListPrivateCloudsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_private_clouds Override in a subclass to manipulate the request or metadata @@ -1851,10 +1964,10 @@ def post_list_private_clouds( def pre_list_private_connection_peering_routes( self, request: vmwareengine.ListPrivateConnectionPeeringRoutesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ vmwareengine.ListPrivateConnectionPeeringRoutesRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_private_connection_peering_routes @@ -1877,8 +1990,11 @@ def post_list_private_connection_peering_routes( def pre_list_private_connections( self, request: vmwareengine.ListPrivateConnectionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListPrivateConnectionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListPrivateConnectionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_private_connections Override in a subclass to manipulate the request or metadata @@ -1900,8 +2016,10 @@ def post_list_private_connections( def pre_list_subnets( self, request: vmwareengine.ListSubnetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListSubnetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListSubnetsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_subnets Override in a subclass to manipulate the request or metadata @@ -1923,8 +2041,11 @@ def post_list_subnets( def pre_list_vmware_engine_networks( self, request: vmwareengine.ListVmwareEngineNetworksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListVmwareEngineNetworksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListVmwareEngineNetworksRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_vmware_engine_networks Override in a subclass to manipulate the request or metadata @@ -1946,9 +2067,10 @@ def post_list_vmware_engine_networks( def pre_repair_management_dns_zone_binding( self, request: vmwareengine.RepairManagementDnsZoneBindingRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - vmwareengine.RepairManagementDnsZoneBindingRequest, Sequence[Tuple[str, str]] + vmwareengine.RepairManagementDnsZoneBindingRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for repair_management_dns_zone_binding @@ -1971,8 +2093,10 @@ def post_repair_management_dns_zone_binding( def pre_reset_nsx_credentials( self, request: vmwareengine.ResetNsxCredentialsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ResetNsxCredentialsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ResetNsxCredentialsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for reset_nsx_credentials Override in a subclass to manipulate the request or metadata @@ -1994,8 +2118,11 @@ def post_reset_nsx_credentials( def pre_reset_vcenter_credentials( self, request: vmwareengine.ResetVcenterCredentialsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ResetVcenterCredentialsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ResetVcenterCredentialsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for reset_vcenter_credentials Override in a subclass to manipulate the request or metadata @@ -2017,8 +2144,11 @@ def post_reset_vcenter_credentials( def pre_revoke_dns_bind_permission( self, request: vmwareengine.RevokeDnsBindPermissionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.RevokeDnsBindPermissionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.RevokeDnsBindPermissionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for revoke_dns_bind_permission Override in a subclass to manipulate the request or metadata @@ -2040,8 +2170,10 @@ def post_revoke_dns_bind_permission( def pre_show_nsx_credentials( self, request: vmwareengine.ShowNsxCredentialsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ShowNsxCredentialsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ShowNsxCredentialsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for show_nsx_credentials Override in a subclass to manipulate the request or metadata @@ -2063,8 +2195,11 @@ def post_show_nsx_credentials( def pre_show_vcenter_credentials( self, request: vmwareengine.ShowVcenterCredentialsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ShowVcenterCredentialsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ShowVcenterCredentialsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for show_vcenter_credentials Override in a subclass to manipulate the request or metadata @@ -2086,8 +2221,11 @@ def post_show_vcenter_credentials( def pre_undelete_private_cloud( self, request: vmwareengine.UndeletePrivateCloudRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.UndeletePrivateCloudRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.UndeletePrivateCloudRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for undelete_private_cloud Override in a subclass to manipulate the request or metadata @@ -2109,8 +2247,10 @@ def post_undelete_private_cloud( def pre_update_cluster( self, request: vmwareengine.UpdateClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.UpdateClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.UpdateClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_cluster Override in a subclass to manipulate the request or metadata @@ -2132,8 +2272,10 @@ def post_update_cluster( def pre_update_dns_forwarding( self, request: vmwareengine.UpdateDnsForwardingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.UpdateDnsForwardingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.UpdateDnsForwardingRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_dns_forwarding Override in a subclass to manipulate the request or metadata @@ -2155,8 +2297,11 @@ def post_update_dns_forwarding( def pre_update_external_access_rule( self, request: vmwareengine.UpdateExternalAccessRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.UpdateExternalAccessRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.UpdateExternalAccessRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_external_access_rule Override in a subclass to manipulate the request or metadata @@ -2178,8 +2323,11 @@ def post_update_external_access_rule( def pre_update_external_address( self, request: vmwareengine.UpdateExternalAddressRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.UpdateExternalAddressRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.UpdateExternalAddressRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_external_address Override in a subclass to manipulate the request or metadata @@ -2201,8 +2349,10 @@ def post_update_external_address( def pre_update_logging_server( self, request: vmwareengine.UpdateLoggingServerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.UpdateLoggingServerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.UpdateLoggingServerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_logging_server Override in a subclass to manipulate the request or metadata @@ -2224,9 +2374,10 @@ def post_update_logging_server( def pre_update_management_dns_zone_binding( self, request: vmwareengine.UpdateManagementDnsZoneBindingRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - vmwareengine.UpdateManagementDnsZoneBindingRequest, Sequence[Tuple[str, str]] + vmwareengine.UpdateManagementDnsZoneBindingRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_management_dns_zone_binding @@ -2249,8 +2400,11 @@ def post_update_management_dns_zone_binding( def pre_update_network_peering( self, request: vmwareengine.UpdateNetworkPeeringRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.UpdateNetworkPeeringRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.UpdateNetworkPeeringRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_network_peering Override in a subclass to manipulate the request or metadata @@ -2272,8 +2426,10 @@ def post_update_network_peering( def pre_update_network_policy( self, request: vmwareengine.UpdateNetworkPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.UpdateNetworkPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.UpdateNetworkPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_network_policy Override in a subclass to manipulate the request or metadata @@ -2295,8 +2451,10 @@ def post_update_network_policy( def pre_update_private_cloud( self, request: vmwareengine.UpdatePrivateCloudRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.UpdatePrivateCloudRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.UpdatePrivateCloudRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_private_cloud Override in a subclass to manipulate the request or metadata @@ -2318,8 +2476,11 @@ def post_update_private_cloud( def pre_update_private_connection( self, request: vmwareengine.UpdatePrivateConnectionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.UpdatePrivateConnectionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.UpdatePrivateConnectionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_private_connection Override in a subclass to manipulate the request or metadata @@ -2341,8 +2502,10 @@ def post_update_private_connection( def pre_update_subnet( self, request: vmwareengine.UpdateSubnetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.UpdateSubnetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.UpdateSubnetRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_subnet Override in a subclass to manipulate the request or metadata @@ -2364,9 +2527,10 @@ def post_update_subnet( def pre_update_vmware_engine_network( self, request: vmwareengine.UpdateVmwareEngineNetworkRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - vmwareengine.UpdateVmwareEngineNetworkRequest, Sequence[Tuple[str, str]] + vmwareengine.UpdateVmwareEngineNetworkRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_vmware_engine_network @@ -2389,8 +2553,10 @@ def post_update_vmware_engine_network( 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 @@ -2412,8 +2578,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 @@ -2435,8 +2603,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 @@ -2456,8 +2626,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 @@ -2477,8 +2649,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 @@ -2500,8 +2675,10 @@ def post_test_iam_permissions( 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 @@ -2521,8 +2698,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 @@ -2544,8 +2723,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 @@ -2733,7 +2914,7 @@ 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. @@ -2744,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: ~.operations_pb2.Operation: @@ -2758,6 +2941,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseCreateCluster._get_http_options() ) + request, metadata = self._interceptor.pre_create_cluster(request, metadata) transcoded_request = _BaseVmwareEngineRestTransport._BaseCreateCluster._get_transcoded_request( http_options, request @@ -2772,6 +2956,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.CreateCluster", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._CreateCluster._get_response( self._host, @@ -2791,7 +3002,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.vmwareengine_v1.VmwareEngineClient.create_cluster", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateExternalAccessRule( @@ -2830,7 +3063,7 @@ 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 external access rule method over HTTP. @@ -2842,8 +3075,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2856,6 +3091,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseCreateExternalAccessRule._get_http_options() ) + request, metadata = self._interceptor.pre_create_external_access_rule( request, metadata ) @@ -2872,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.CreateExternalAccessRule", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateExternalAccessRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._CreateExternalAccessRule._get_response( @@ -2893,7 +3156,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_external_access_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.create_external_access_rule", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateExternalAccessRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateExternalAddress( @@ -2931,7 +3216,7 @@ 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 external address method over HTTP. @@ -2942,8 +3227,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2956,6 +3243,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseCreateExternalAddress._get_http_options() ) + request, metadata = self._interceptor.pre_create_external_address( request, metadata ) @@ -2972,6 +3260,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.CreateExternalAddress", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateExternalAddress", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._CreateExternalAddress._get_response( self._host, @@ -2991,7 +3306,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_external_address(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.create_external_address", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateExternalAddress", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateHcxActivationKey( @@ -3029,7 +3366,7 @@ 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 hcx activation key method over HTTP. @@ -3040,8 +3377,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3054,6 +3393,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseCreateHcxActivationKey._get_http_options() ) + request, metadata = self._interceptor.pre_create_hcx_activation_key( request, metadata ) @@ -3070,6 +3410,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.CreateHcxActivationKey", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateHcxActivationKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._CreateHcxActivationKey._get_response( self._host, @@ -3089,7 +3456,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_hcx_activation_key(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.create_hcx_activation_key", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateHcxActivationKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateLoggingServer( @@ -3127,7 +3516,7 @@ 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 logging server method over HTTP. @@ -3138,8 +3527,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3152,6 +3543,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseCreateLoggingServer._get_http_options() ) + request, metadata = self._interceptor.pre_create_logging_server( request, metadata ) @@ -3168,6 +3560,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.CreateLoggingServer", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateLoggingServer", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._CreateLoggingServer._get_response( self._host, @@ -3187,7 +3606,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_logging_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.vmwareengine_v1.VmwareEngineClient.create_logging_server", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateLoggingServer", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateManagementDnsZoneBinding( @@ -3226,7 +3667,7 @@ 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 management dns zone binding method over HTTP. @@ -3238,8 +3679,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3252,6 +3695,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseCreateManagementDnsZoneBinding._get_http_options() ) + ( request, metadata, @@ -3271,6 +3715,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.CreateManagementDnsZoneBinding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateManagementDnsZoneBinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._CreateManagementDnsZoneBinding._get_response( @@ -3292,7 +3763,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_management_dns_zone_binding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.create_management_dns_zone_binding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateManagementDnsZoneBinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateNetworkPeering( @@ -3330,7 +3823,7 @@ 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 network peering method over HTTP. @@ -3341,8 +3834,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3355,6 +3850,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseCreateNetworkPeering._get_http_options() ) + request, metadata = self._interceptor.pre_create_network_peering( request, metadata ) @@ -3371,6 +3867,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.CreateNetworkPeering", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateNetworkPeering", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._CreateNetworkPeering._get_response( self._host, @@ -3390,7 +3913,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_network_peering(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.create_network_peering", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateNetworkPeering", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateNetworkPolicy( @@ -3428,7 +3973,7 @@ 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 network policy method over HTTP. @@ -3439,8 +3984,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3453,6 +4000,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseCreateNetworkPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_create_network_policy( request, metadata ) @@ -3469,6 +4017,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.CreateNetworkPolicy", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateNetworkPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._CreateNetworkPolicy._get_response( self._host, @@ -3488,7 +4063,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_network_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.vmwareengine_v1.VmwareEngineClient.create_network_policy", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateNetworkPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreatePrivateCloud( @@ -3526,7 +4123,7 @@ 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 private cloud method over HTTP. @@ -3537,8 +4134,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3551,6 +4150,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseCreatePrivateCloud._get_http_options() ) + request, metadata = self._interceptor.pre_create_private_cloud( request, metadata ) @@ -3567,6 +4167,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.CreatePrivateCloud", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreatePrivateCloud", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._CreatePrivateCloud._get_response( self._host, @@ -3586,7 +4213,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_private_cloud(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.create_private_cloud", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreatePrivateCloud", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreatePrivateConnection( @@ -3625,7 +4274,7 @@ 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 private connection method over HTTP. @@ -3636,8 +4285,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3650,6 +4301,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseCreatePrivateConnection._get_http_options() ) + request, metadata = self._interceptor.pre_create_private_connection( request, metadata ) @@ -3666,6 +4318,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.CreatePrivateConnection", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreatePrivateConnection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._CreatePrivateConnection._get_response( self._host, @@ -3685,7 +4364,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_private_connection(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.create_private_connection", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreatePrivateConnection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateVmwareEngineNetwork( @@ -3724,7 +4425,7 @@ 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 vmware engine network method over HTTP. @@ -3736,8 +4437,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3750,6 +4453,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseCreateVmwareEngineNetwork._get_http_options() ) + request, metadata = self._interceptor.pre_create_vmware_engine_network( request, metadata ) @@ -3766,6 +4470,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.CreateVmwareEngineNetwork", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateVmwareEngineNetwork", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._CreateVmwareEngineNetwork._get_response( @@ -3787,7 +4518,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_vmware_engine_network(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.create_vmware_engine_network", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateVmwareEngineNetwork", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCluster( @@ -3824,7 +4577,7 @@ 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. @@ -3835,8 +4588,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3849,6 +4604,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseDeleteCluster._get_http_options() ) + request, metadata = self._interceptor.pre_delete_cluster(request, metadata) transcoded_request = _BaseVmwareEngineRestTransport._BaseDeleteCluster._get_transcoded_request( http_options, request @@ -3859,6 +4615,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.DeleteCluster", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._DeleteCluster._get_response( self._host, @@ -3877,7 +4660,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.vmwareengine_v1.VmwareEngineClient.delete_cluster", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteExternalAccessRule( @@ -3915,7 +4720,7 @@ 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 external access rule method over HTTP. @@ -3927,8 +4732,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3941,6 +4748,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseDeleteExternalAccessRule._get_http_options() ) + request, metadata = self._interceptor.pre_delete_external_access_rule( request, metadata ) @@ -3953,6 +4761,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.DeleteExternalAccessRule", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteExternalAccessRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._DeleteExternalAccessRule._get_response( @@ -3973,7 +4808,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_external_access_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.delete_external_access_rule", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteExternalAccessRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteExternalAddress( @@ -4010,7 +4867,7 @@ 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 external address method over HTTP. @@ -4021,8 +4878,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4035,6 +4894,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseDeleteExternalAddress._get_http_options() ) + request, metadata = self._interceptor.pre_delete_external_address( request, metadata ) @@ -4047,6 +4907,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.DeleteExternalAddress", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteExternalAddress", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._DeleteExternalAddress._get_response( self._host, @@ -4065,7 +4952,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_external_address(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.delete_external_address", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteExternalAddress", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteLoggingServer( @@ -4102,7 +5011,7 @@ 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 logging server method over HTTP. @@ -4113,8 +5022,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4127,6 +5038,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseDeleteLoggingServer._get_http_options() ) + request, metadata = self._interceptor.pre_delete_logging_server( request, metadata ) @@ -4139,6 +5051,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.DeleteLoggingServer", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteLoggingServer", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._DeleteLoggingServer._get_response( self._host, @@ -4157,7 +5096,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_logging_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.vmwareengine_v1.VmwareEngineClient.delete_logging_server", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteLoggingServer", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteManagementDnsZoneBinding( @@ -4195,7 +5156,7 @@ 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 management dns zone binding method over HTTP. @@ -4207,8 +5168,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4221,6 +5184,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseDeleteManagementDnsZoneBinding._get_http_options() ) + ( request, metadata, @@ -4236,6 +5200,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.DeleteManagementDnsZoneBinding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteManagementDnsZoneBinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._DeleteManagementDnsZoneBinding._get_response( @@ -4256,7 +5247,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_management_dns_zone_binding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.delete_management_dns_zone_binding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteManagementDnsZoneBinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteNetworkPeering( @@ -4293,7 +5306,7 @@ 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 network peering method over HTTP. @@ -4304,8 +5317,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4318,6 +5333,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseDeleteNetworkPeering._get_http_options() ) + request, metadata = self._interceptor.pre_delete_network_peering( request, metadata ) @@ -4330,6 +5346,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.DeleteNetworkPeering", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteNetworkPeering", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._DeleteNetworkPeering._get_response( self._host, @@ -4348,7 +5391,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_network_peering(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.delete_network_peering", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteNetworkPeering", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteNetworkPolicy( @@ -4385,7 +5450,7 @@ 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 network policy method over HTTP. @@ -4396,8 +5461,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4410,6 +5477,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseDeleteNetworkPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_delete_network_policy( request, metadata ) @@ -4422,6 +5490,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.DeleteNetworkPolicy", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteNetworkPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._DeleteNetworkPolicy._get_response( self._host, @@ -4440,7 +5535,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_network_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.vmwareengine_v1.VmwareEngineClient.delete_network_policy", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteNetworkPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeletePrivateCloud( @@ -4477,7 +5594,7 @@ 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 private cloud method over HTTP. @@ -4488,8 +5605,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4502,6 +5621,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseDeletePrivateCloud._get_http_options() ) + request, metadata = self._interceptor.pre_delete_private_cloud( request, metadata ) @@ -4514,6 +5634,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.DeletePrivateCloud", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeletePrivateCloud", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._DeletePrivateCloud._get_response( self._host, @@ -4532,7 +5679,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_private_cloud(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.delete_private_cloud", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeletePrivateCloud", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeletePrivateConnection( @@ -4570,7 +5739,7 @@ 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 private connection method over HTTP. @@ -4581,8 +5750,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4595,6 +5766,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseDeletePrivateConnection._get_http_options() ) + request, metadata = self._interceptor.pre_delete_private_connection( request, metadata ) @@ -4607,6 +5779,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.DeletePrivateConnection", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeletePrivateConnection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._DeletePrivateConnection._get_response( self._host, @@ -4625,7 +5824,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_private_connection(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.delete_private_connection", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeletePrivateConnection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteVmwareEngineNetwork( @@ -4663,7 +5884,7 @@ 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 vmware engine network method over HTTP. @@ -4675,8 +5896,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4689,6 +5912,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseDeleteVmwareEngineNetwork._get_http_options() ) + request, metadata = self._interceptor.pre_delete_vmware_engine_network( request, metadata ) @@ -4701,6 +5925,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.DeleteVmwareEngineNetwork", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteVmwareEngineNetwork", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._DeleteVmwareEngineNetwork._get_response( @@ -4721,7 +5972,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_vmware_engine_network(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.delete_vmware_engine_network", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteVmwareEngineNetwork", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _FetchNetworkPolicyExternalAddresses( @@ -4759,7 +6032,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.FetchNetworkPolicyExternalAddressesResponse: r"""Call the fetch network policy external addresses method over HTTP. @@ -4771,8 +6044,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine.FetchNetworkPolicyExternalAddressesResponse: @@ -4784,6 +6059,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseFetchNetworkPolicyExternalAddresses._get_http_options() ) + ( request, metadata, @@ -4799,6 +6075,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.FetchNetworkPolicyExternalAddresses", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "FetchNetworkPolicyExternalAddresses", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._FetchNetworkPolicyExternalAddresses._get_response( self._host, @@ -4819,7 +6122,31 @@ def __call__( pb_resp = vmwareengine.FetchNetworkPolicyExternalAddressesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_fetch_network_policy_external_addresses(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine.FetchNetworkPolicyExternalAddressesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.fetch_network_policy_external_addresses", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "FetchNetworkPolicyExternalAddresses", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCluster( @@ -4856,7 +6183,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Cluster: r"""Call the get cluster method over HTTP. @@ -4867,8 +6194,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine_resources.Cluster: @@ -4878,6 +6207,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetCluster._get_http_options() ) + request, metadata = self._interceptor.pre_get_cluster(request, metadata) transcoded_request = ( _BaseVmwareEngineRestTransport._BaseGetCluster._get_transcoded_request( @@ -4892,6 +6222,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.GetCluster", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetCluster._get_response( self._host, @@ -4912,7 +6269,29 @@ def __call__( pb_resp = vmwareengine_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 = vmwareengine_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.vmwareengine_v1.VmwareEngineClient.get_cluster", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDnsBindPermission( @@ -4949,7 +6328,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.DnsBindPermission: r"""Call the get dns bind permission method over HTTP. @@ -4960,8 +6339,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine_resources.DnsBindPermission: @@ -4976,6 +6357,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetDnsBindPermission._get_http_options() ) + request, metadata = self._interceptor.pre_get_dns_bind_permission( request, metadata ) @@ -4988,6 +6370,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.GetDnsBindPermission", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetDnsBindPermission", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetDnsBindPermission._get_response( self._host, @@ -5008,7 +6417,31 @@ def __call__( pb_resp = vmwareengine_resources.DnsBindPermission.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_dns_bind_permission(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.DnsBindPermission.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.get_dns_bind_permission", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetDnsBindPermission", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDnsForwarding( @@ -5045,7 +6478,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.DnsForwarding: r"""Call the get dns forwarding method over HTTP. @@ -5056,8 +6489,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine_resources.DnsForwarding: @@ -5072,6 +6507,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetDnsForwarding._get_http_options() ) + request, metadata = self._interceptor.pre_get_dns_forwarding( request, metadata ) @@ -5084,6 +6520,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.GetDnsForwarding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetDnsForwarding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetDnsForwarding._get_response( self._host, @@ -5104,7 +6567,31 @@ def __call__( pb_resp = vmwareengine_resources.DnsForwarding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_dns_forwarding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.DnsForwarding.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.get_dns_forwarding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetDnsForwarding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetExternalAccessRule( @@ -5141,7 +6628,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.ExternalAccessRule: r"""Call the get external access rule method over HTTP. @@ -5152,8 +6639,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine_resources.ExternalAccessRule: @@ -5165,6 +6654,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetExternalAccessRule._get_http_options() ) + request, metadata = self._interceptor.pre_get_external_access_rule( request, metadata ) @@ -5177,6 +6667,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.GetExternalAccessRule", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetExternalAccessRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetExternalAccessRule._get_response( self._host, @@ -5197,7 +6714,31 @@ def __call__( pb_resp = vmwareengine_resources.ExternalAccessRule.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_external_access_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmwareengine_resources.ExternalAccessRule.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.get_external_access_rule", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetExternalAccessRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetExternalAddress( @@ -5234,7 +6775,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.ExternalAddress: r"""Call the get external address method over HTTP. @@ -5245,8 +6786,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine_resources.ExternalAddress: @@ -5259,6 +6802,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetExternalAddress._get_http_options() ) + request, metadata = self._interceptor.pre_get_external_address( request, metadata ) @@ -5271,6 +6815,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.GetExternalAddress", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetExternalAddress", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetExternalAddress._get_response( self._host, @@ -5291,7 +6862,31 @@ def __call__( pb_resp = vmwareengine_resources.ExternalAddress.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_external_address(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.ExternalAddress.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.get_external_address", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetExternalAddress", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetHcxActivationKey( @@ -5328,7 +6923,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.HcxActivationKey: r"""Call the get hcx activation key method over HTTP. @@ -5339,8 +6934,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine_resources.HcxActivationKey: @@ -5357,6 +6954,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetHcxActivationKey._get_http_options() ) + request, metadata = self._interceptor.pre_get_hcx_activation_key( request, metadata ) @@ -5369,6 +6967,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.GetHcxActivationKey", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetHcxActivationKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetHcxActivationKey._get_response( self._host, @@ -5389,7 +7014,31 @@ def __call__( pb_resp = vmwareengine_resources.HcxActivationKey.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_hcx_activation_key(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.HcxActivationKey.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.get_hcx_activation_key", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetHcxActivationKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetLoggingServer( @@ -5426,7 +7075,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.LoggingServer: r"""Call the get logging server method over HTTP. @@ -5437,8 +7086,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine_resources.LoggingServer: @@ -5450,6 +7101,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetLoggingServer._get_http_options() ) + request, metadata = self._interceptor.pre_get_logging_server( request, metadata ) @@ -5462,6 +7114,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.GetLoggingServer", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetLoggingServer", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetLoggingServer._get_response( self._host, @@ -5482,7 +7161,31 @@ def __call__( pb_resp = vmwareengine_resources.LoggingServer.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_logging_server(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.LoggingServer.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.get_logging_server", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetLoggingServer", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetManagementDnsZoneBinding( @@ -5520,7 +7223,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.ManagementDnsZoneBinding: r"""Call the get management dns zone binding method over HTTP. @@ -5532,8 +7235,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine_resources.ManagementDnsZoneBinding: @@ -5552,6 +7257,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetManagementDnsZoneBinding._get_http_options() ) + request, metadata = self._interceptor.pre_get_management_dns_zone_binding( request, metadata ) @@ -5564,6 +7270,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.GetManagementDnsZoneBinding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetManagementDnsZoneBinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._GetManagementDnsZoneBinding._get_response( @@ -5586,7 +7319,33 @@ def __call__( pb_resp = vmwareengine_resources.ManagementDnsZoneBinding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_management_dns_zone_binding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmwareengine_resources.ManagementDnsZoneBinding.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.get_management_dns_zone_binding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetManagementDnsZoneBinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetNetworkPeering( @@ -5623,7 +7382,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.NetworkPeering: r"""Call the get network peering method over HTTP. @@ -5634,8 +7393,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine_resources.NetworkPeering: @@ -5645,6 +7406,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetNetworkPeering._get_http_options() ) + request, metadata = self._interceptor.pre_get_network_peering( request, metadata ) @@ -5657,6 +7419,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.GetNetworkPeering", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetNetworkPeering", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetNetworkPeering._get_response( self._host, @@ -5677,7 +7466,31 @@ def __call__( pb_resp = vmwareengine_resources.NetworkPeering.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_network_peering(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.NetworkPeering.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.get_network_peering", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetNetworkPeering", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetNetworkPolicy( @@ -5714,7 +7527,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.NetworkPolicy: r"""Call the get network policy method over HTTP. @@ -5725,8 +7538,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine_resources.NetworkPolicy: @@ -5747,6 +7562,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetNetworkPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_network_policy( request, metadata ) @@ -5759,6 +7575,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.GetNetworkPolicy", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetNetworkPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetNetworkPolicy._get_response( self._host, @@ -5779,7 +7622,31 @@ def __call__( pb_resp = vmwareengine_resources.NetworkPolicy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_network_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.NetworkPolicy.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.get_network_policy", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetNetworkPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetNode(_BaseVmwareEngineRestTransport._BaseGetNode, VmwareEngineRestStub): @@ -5814,7 +7681,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Node: r"""Call the get node method over HTTP. @@ -5825,8 +7692,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine_resources.Node: @@ -5836,6 +7705,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetNode._get_http_options() ) + request, metadata = self._interceptor.pre_get_node(request, metadata) transcoded_request = ( _BaseVmwareEngineRestTransport._BaseGetNode._get_transcoded_request( @@ -5850,6 +7720,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.GetNode", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetNode", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetNode._get_response( self._host, @@ -5870,7 +7767,29 @@ def __call__( pb_resp = vmwareengine_resources.Node.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_node(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.Node.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.get_node", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetNode", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetNodeType( @@ -5907,7 +7826,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.NodeType: r"""Call the get node type method over HTTP. @@ -5918,8 +7837,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine_resources.NodeType: @@ -5929,6 +7850,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetNodeType._get_http_options() ) + request, metadata = self._interceptor.pre_get_node_type(request, metadata) transcoded_request = ( _BaseVmwareEngineRestTransport._BaseGetNodeType._get_transcoded_request( @@ -5943,6 +7865,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.GetNodeType", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetNodeType", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetNodeType._get_response( self._host, @@ -5963,7 +7912,29 @@ def __call__( pb_resp = vmwareengine_resources.NodeType.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_node_type(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.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.vmwareengine_v1.VmwareEngineClient.get_node_type", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetNodeType", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetPrivateCloud( @@ -6000,7 +7971,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.PrivateCloud: r"""Call the get private cloud method over HTTP. @@ -6011,8 +7982,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine_resources.PrivateCloud: @@ -6025,6 +7998,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetPrivateCloud._get_http_options() ) + request, metadata = self._interceptor.pre_get_private_cloud( request, metadata ) @@ -6037,6 +8011,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.GetPrivateCloud", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetPrivateCloud", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetPrivateCloud._get_response( self._host, @@ -6057,7 +8058,31 @@ def __call__( pb_resp = vmwareengine_resources.PrivateCloud.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_private_cloud(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.PrivateCloud.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.get_private_cloud", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetPrivateCloud", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetPrivateConnection( @@ -6094,7 +8119,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.PrivateConnection: r"""Call the get private connection method over HTTP. @@ -6105,8 +8130,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine_resources.PrivateConnection: @@ -6119,6 +8146,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetPrivateConnection._get_http_options() ) + request, metadata = self._interceptor.pre_get_private_connection( request, metadata ) @@ -6131,6 +8159,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.GetPrivateConnection", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetPrivateConnection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetPrivateConnection._get_response( self._host, @@ -6151,7 +8206,31 @@ def __call__( pb_resp = vmwareengine_resources.PrivateConnection.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_private_connection(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.PrivateConnection.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.get_private_connection", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetPrivateConnection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSubnet( @@ -6188,7 +8267,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Subnet: r"""Call the get subnet method over HTTP. @@ -6199,8 +8278,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine_resources.Subnet: @@ -6213,6 +8294,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetSubnet._get_http_options() ) + request, metadata = self._interceptor.pre_get_subnet(request, metadata) transcoded_request = ( _BaseVmwareEngineRestTransport._BaseGetSubnet._get_transcoded_request( @@ -6227,6 +8309,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.GetSubnet", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetSubnet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetSubnet._get_response( self._host, @@ -6247,7 +8356,29 @@ def __call__( pb_resp = vmwareengine_resources.Subnet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_subnet(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.Subnet.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.get_subnet", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetSubnet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetVmwareEngineNetwork( @@ -6284,7 +8415,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.VmwareEngineNetwork: r"""Call the get vmware engine network method over HTTP. @@ -6295,8 +8426,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine_resources.VmwareEngineNetwork: @@ -6309,6 +8442,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetVmwareEngineNetwork._get_http_options() ) + request, metadata = self._interceptor.pre_get_vmware_engine_network( request, metadata ) @@ -6321,6 +8455,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.GetVmwareEngineNetwork", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetVmwareEngineNetwork", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetVmwareEngineNetwork._get_response( self._host, @@ -6341,7 +8502,31 @@ def __call__( pb_resp = vmwareengine_resources.VmwareEngineNetwork.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_vmware_engine_network(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmwareengine_resources.VmwareEngineNetwork.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.get_vmware_engine_network", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetVmwareEngineNetwork", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GrantDnsBindPermission( @@ -6379,7 +8564,7 @@ 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 grant dns bind permission method over HTTP. @@ -6390,8 +8575,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -6404,6 +8591,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGrantDnsBindPermission._get_http_options() ) + request, metadata = self._interceptor.pre_grant_dns_bind_permission( request, metadata ) @@ -6420,6 +8608,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.GrantDnsBindPermission", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GrantDnsBindPermission", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GrantDnsBindPermission._get_response( self._host, @@ -6439,7 +8654,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_grant_dns_bind_permission(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.grant_dns_bind_permission", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GrantDnsBindPermission", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListClusters( @@ -6476,7 +8713,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListClustersResponse: r"""Call the list clusters method over HTTP. @@ -6487,8 +8724,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine.ListClustersResponse: @@ -6500,6 +8739,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListClusters._get_http_options() ) + request, metadata = self._interceptor.pre_list_clusters(request, metadata) transcoded_request = _BaseVmwareEngineRestTransport._BaseListClusters._get_transcoded_request( http_options, request @@ -6512,6 +8752,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.ListClusters", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListClusters", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListClusters._get_response( self._host, @@ -6532,7 +8799,31 @@ def __call__( pb_resp = vmwareengine.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 = vmwareengine.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.vmwareengine_v1.VmwareEngineClient.list_clusters", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListClusters", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListExternalAccessRules( @@ -6570,7 +8861,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListExternalAccessRulesResponse: r"""Call the list external access rules method over HTTP. @@ -6582,8 +8873,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine.ListExternalAccessRulesResponse: @@ -6595,6 +8888,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListExternalAccessRules._get_http_options() ) + request, metadata = self._interceptor.pre_list_external_access_rules( request, metadata ) @@ -6607,6 +8901,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.ListExternalAccessRules", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListExternalAccessRules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListExternalAccessRules._get_response( self._host, @@ -6627,7 +8948,31 @@ def __call__( pb_resp = vmwareengine.ListExternalAccessRulesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_external_access_rules(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmwareengine.ListExternalAccessRulesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.list_external_access_rules", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListExternalAccessRules", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListExternalAddresses( @@ -6664,7 +9009,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListExternalAddressesResponse: r"""Call the list external addresses method over HTTP. @@ -6675,8 +9020,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine.ListExternalAddressesResponse: @@ -6688,6 +9035,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListExternalAddresses._get_http_options() ) + request, metadata = self._interceptor.pre_list_external_addresses( request, metadata ) @@ -6700,6 +9048,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.ListExternalAddresses", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListExternalAddresses", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListExternalAddresses._get_response( self._host, @@ -6720,7 +9095,31 @@ def __call__( pb_resp = vmwareengine.ListExternalAddressesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_external_addresses(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmwareengine.ListExternalAddressesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.list_external_addresses", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListExternalAddresses", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListHcxActivationKeys( @@ -6757,7 +9156,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListHcxActivationKeysResponse: r"""Call the list hcx activation keys method over HTTP. @@ -6768,8 +9167,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine.ListHcxActivationKeysResponse: @@ -6781,6 +9182,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListHcxActivationKeys._get_http_options() ) + request, metadata = self._interceptor.pre_list_hcx_activation_keys( request, metadata ) @@ -6793,6 +9195,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.ListHcxActivationKeys", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListHcxActivationKeys", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListHcxActivationKeys._get_response( self._host, @@ -6813,7 +9242,31 @@ def __call__( pb_resp = vmwareengine.ListHcxActivationKeysResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_hcx_activation_keys(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmwareengine.ListHcxActivationKeysResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.list_hcx_activation_keys", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListHcxActivationKeys", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListLoggingServers( @@ -6850,7 +9303,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListLoggingServersResponse: r"""Call the list logging servers method over HTTP. @@ -6861,8 +9314,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine.ListLoggingServersResponse: @@ -6874,6 +9329,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListLoggingServers._get_http_options() ) + request, metadata = self._interceptor.pre_list_logging_servers( request, metadata ) @@ -6886,6 +9342,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.ListLoggingServers", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListLoggingServers", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListLoggingServers._get_response( self._host, @@ -6906,7 +9389,31 @@ def __call__( pb_resp = vmwareengine.ListLoggingServersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_logging_servers(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine.ListLoggingServersResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.list_logging_servers", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListLoggingServers", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListManagementDnsZoneBindings( @@ -6944,7 +9451,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListManagementDnsZoneBindingsResponse: r"""Call the list management dns zone bindings method over HTTP. @@ -6956,8 +9463,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine.ListManagementDnsZoneBindingsResponse: @@ -6969,6 +9478,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListManagementDnsZoneBindings._get_http_options() ) + request, metadata = self._interceptor.pre_list_management_dns_zone_bindings( request, metadata ) @@ -6981,6 +9491,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.ListManagementDnsZoneBindings", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListManagementDnsZoneBindings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._ListManagementDnsZoneBindings._get_response( @@ -7003,7 +9540,33 @@ def __call__( pb_resp = vmwareengine.ListManagementDnsZoneBindingsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_management_dns_zone_bindings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmwareengine.ListManagementDnsZoneBindingsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.list_management_dns_zone_bindings", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListManagementDnsZoneBindings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListNetworkPeerings( @@ -7040,7 +9603,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListNetworkPeeringsResponse: r"""Call the list network peerings method over HTTP. @@ -7051,8 +9614,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine.ListNetworkPeeringsResponse: @@ -7064,6 +9629,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListNetworkPeerings._get_http_options() ) + request, metadata = self._interceptor.pre_list_network_peerings( request, metadata ) @@ -7076,6 +9642,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.ListNetworkPeerings", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListNetworkPeerings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListNetworkPeerings._get_response( self._host, @@ -7096,7 +9689,31 @@ def __call__( pb_resp = vmwareengine.ListNetworkPeeringsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_network_peerings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine.ListNetworkPeeringsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.list_network_peerings", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListNetworkPeerings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListNetworkPolicies( @@ -7133,7 +9750,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListNetworkPoliciesResponse: r"""Call the list network policies method over HTTP. @@ -7144,8 +9761,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine.ListNetworkPoliciesResponse: @@ -7157,6 +9776,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListNetworkPolicies._get_http_options() ) + request, metadata = self._interceptor.pre_list_network_policies( request, metadata ) @@ -7169,6 +9789,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.ListNetworkPolicies", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListNetworkPolicies", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListNetworkPolicies._get_response( self._host, @@ -7189,7 +9836,31 @@ def __call__( pb_resp = vmwareengine.ListNetworkPoliciesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_network_policies(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine.ListNetworkPoliciesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.list_network_policies", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListNetworkPolicies", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListNodes( @@ -7226,7 +9897,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListNodesResponse: r"""Call the list nodes method over HTTP. @@ -7237,8 +9908,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine.ListNodesResponse: @@ -7250,6 +9923,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListNodes._get_http_options() ) + request, metadata = self._interceptor.pre_list_nodes(request, metadata) transcoded_request = ( _BaseVmwareEngineRestTransport._BaseListNodes._get_transcoded_request( @@ -7264,6 +9938,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.ListNodes", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListNodes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListNodes._get_response( self._host, @@ -7284,7 +9985,29 @@ def __call__( pb_resp = vmwareengine.ListNodesResponse.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 = vmwareengine.ListNodesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.list_nodes", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListNodes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListNodeTypes( @@ -7321,7 +10044,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListNodeTypesResponse: r"""Call the list node types method over HTTP. @@ -7332,8 +10055,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine.ListNodeTypesResponse: @@ -7345,6 +10070,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListNodeTypes._get_http_options() ) + request, metadata = self._interceptor.pre_list_node_types(request, metadata) transcoded_request = _BaseVmwareEngineRestTransport._BaseListNodeTypes._get_transcoded_request( http_options, request @@ -7355,6 +10081,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.ListNodeTypes", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListNodeTypes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListNodeTypes._get_response( self._host, @@ -7375,7 +10128,31 @@ def __call__( pb_resp = vmwareengine.ListNodeTypesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_node_types(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine.ListNodeTypesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.list_node_types", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListNodeTypes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPeeringRoutes( @@ -7412,7 +10189,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListPeeringRoutesResponse: r"""Call the list peering routes method over HTTP. @@ -7423,8 +10200,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine.ListPeeringRoutesResponse: @@ -7436,6 +10215,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListPeeringRoutes._get_http_options() ) + request, metadata = self._interceptor.pre_list_peering_routes( request, metadata ) @@ -7448,6 +10228,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.ListPeeringRoutes", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListPeeringRoutes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListPeeringRoutes._get_response( self._host, @@ -7468,7 +10275,31 @@ def __call__( pb_resp = vmwareengine.ListPeeringRoutesResponse.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 = vmwareengine.ListPeeringRoutesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.list_peering_routes", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListPeeringRoutes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPrivateClouds( @@ -7505,7 +10336,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListPrivateCloudsResponse: r"""Call the list private clouds method over HTTP. @@ -7516,8 +10347,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine.ListPrivateCloudsResponse: @@ -7529,6 +10362,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListPrivateClouds._get_http_options() ) + request, metadata = self._interceptor.pre_list_private_clouds( request, metadata ) @@ -7541,6 +10375,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.ListPrivateClouds", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListPrivateClouds", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListPrivateClouds._get_response( self._host, @@ -7561,7 +10422,31 @@ def __call__( pb_resp = vmwareengine.ListPrivateCloudsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_private_clouds(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine.ListPrivateCloudsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.list_private_clouds", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListPrivateClouds", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPrivateConnectionPeeringRoutes( @@ -7599,7 +10484,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListPrivateConnectionPeeringRoutesResponse: r"""Call the list private connection peering routes method over HTTP. @@ -7611,8 +10496,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine.ListPrivateConnectionPeeringRoutesResponse: @@ -7624,6 +10511,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListPrivateConnectionPeeringRoutes._get_http_options() ) + ( request, metadata, @@ -7639,6 +10527,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.ListPrivateConnectionPeeringRoutes", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListPrivateConnectionPeeringRoutes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListPrivateConnectionPeeringRoutes._get_response( self._host, @@ -7659,7 +10574,33 @@ def __call__( pb_resp = vmwareengine.ListPrivateConnectionPeeringRoutesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_private_connection_peering_routes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmwareengine.ListPrivateConnectionPeeringRoutesResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.list_private_connection_peering_routes", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListPrivateConnectionPeeringRoutes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPrivateConnections( @@ -7696,7 +10637,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListPrivateConnectionsResponse: r"""Call the list private connections method over HTTP. @@ -7707,8 +10648,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine.ListPrivateConnectionsResponse: @@ -7720,6 +10663,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListPrivateConnections._get_http_options() ) + request, metadata = self._interceptor.pre_list_private_connections( request, metadata ) @@ -7732,6 +10676,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.ListPrivateConnections", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListPrivateConnections", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListPrivateConnections._get_response( self._host, @@ -7752,7 +10723,31 @@ def __call__( pb_resp = vmwareengine.ListPrivateConnectionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_private_connections(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmwareengine.ListPrivateConnectionsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.list_private_connections", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListPrivateConnections", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSubnets( @@ -7789,7 +10784,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListSubnetsResponse: r"""Call the list subnets method over HTTP. @@ -7800,8 +10795,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine.ListSubnetsResponse: @@ -7813,6 +10810,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListSubnets._get_http_options() ) + request, metadata = self._interceptor.pre_list_subnets(request, metadata) transcoded_request = ( _BaseVmwareEngineRestTransport._BaseListSubnets._get_transcoded_request( @@ -7827,6 +10825,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.ListSubnets", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListSubnets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListSubnets._get_response( self._host, @@ -7847,7 +10872,31 @@ def __call__( pb_resp = vmwareengine.ListSubnetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_subnets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine.ListSubnetsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.list_subnets", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListSubnets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListVmwareEngineNetworks( @@ -7885,7 +10934,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListVmwareEngineNetworksResponse: r"""Call the list vmware engine networks method over HTTP. @@ -7897,8 +10946,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine.ListVmwareEngineNetworksResponse: @@ -7910,6 +10961,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListVmwareEngineNetworks._get_http_options() ) + request, metadata = self._interceptor.pre_list_vmware_engine_networks( request, metadata ) @@ -7922,6 +10974,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.ListVmwareEngineNetworks", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListVmwareEngineNetworks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._ListVmwareEngineNetworks._get_response( @@ -7944,7 +11023,31 @@ def __call__( pb_resp = vmwareengine.ListVmwareEngineNetworksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_vmware_engine_networks(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmwareengine.ListVmwareEngineNetworksResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.list_vmware_engine_networks", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListVmwareEngineNetworks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RepairManagementDnsZoneBinding( @@ -7983,7 +11086,7 @@ 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 repair management dns zone binding method over HTTP. @@ -7995,8 +11098,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -8009,6 +11114,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseRepairManagementDnsZoneBinding._get_http_options() ) + ( request, metadata, @@ -8028,6 +11134,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.RepairManagementDnsZoneBinding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "RepairManagementDnsZoneBinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._RepairManagementDnsZoneBinding._get_response( @@ -8049,7 +11182,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_repair_management_dns_zone_binding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.repair_management_dns_zone_binding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "RepairManagementDnsZoneBinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ResetNsxCredentials( @@ -8087,7 +11242,7 @@ 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 reset nsx credentials method over HTTP. @@ -8098,8 +11253,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -8112,6 +11269,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseResetNsxCredentials._get_http_options() ) + request, metadata = self._interceptor.pre_reset_nsx_credentials( request, metadata ) @@ -8128,6 +11286,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.ResetNsxCredentials", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ResetNsxCredentials", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ResetNsxCredentials._get_response( self._host, @@ -8147,7 +11332,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_reset_nsx_credentials(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.reset_nsx_credentials", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ResetNsxCredentials", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ResetVcenterCredentials( @@ -8186,7 +11393,7 @@ 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 reset vcenter credentials method over HTTP. @@ -8197,8 +11404,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -8211,6 +11420,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseResetVcenterCredentials._get_http_options() ) + request, metadata = self._interceptor.pre_reset_vcenter_credentials( request, metadata ) @@ -8227,6 +11437,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.ResetVcenterCredentials", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ResetVcenterCredentials", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ResetVcenterCredentials._get_response( self._host, @@ -8246,7 +11483,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_reset_vcenter_credentials(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.reset_vcenter_credentials", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ResetVcenterCredentials", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RevokeDnsBindPermission( @@ -8285,7 +11544,7 @@ 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 revoke dns bind permission method over HTTP. @@ -8297,8 +11556,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -8311,6 +11572,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseRevokeDnsBindPermission._get_http_options() ) + request, metadata = self._interceptor.pre_revoke_dns_bind_permission( request, metadata ) @@ -8327,6 +11589,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.RevokeDnsBindPermission", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "RevokeDnsBindPermission", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._RevokeDnsBindPermission._get_response( self._host, @@ -8346,7 +11635,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_revoke_dns_bind_permission(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.revoke_dns_bind_permission", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "RevokeDnsBindPermission", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ShowNsxCredentials( @@ -8383,7 +11694,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Credentials: r"""Call the show nsx credentials method over HTTP. @@ -8394,8 +11705,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine_resources.Credentials: @@ -8405,6 +11718,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseShowNsxCredentials._get_http_options() ) + request, metadata = self._interceptor.pre_show_nsx_credentials( request, metadata ) @@ -8417,6 +11731,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.ShowNsxCredentials", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ShowNsxCredentials", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ShowNsxCredentials._get_response( self._host, @@ -8437,7 +11778,31 @@ def __call__( pb_resp = vmwareengine_resources.Credentials.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_show_nsx_credentials(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.Credentials.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.show_nsx_credentials", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ShowNsxCredentials", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ShowVcenterCredentials( @@ -8474,7 +11839,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Credentials: r"""Call the show vcenter credentials method over HTTP. @@ -8485,8 +11850,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vmwareengine_resources.Credentials: @@ -8496,6 +11863,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseShowVcenterCredentials._get_http_options() ) + request, metadata = self._interceptor.pre_show_vcenter_credentials( request, metadata ) @@ -8508,6 +11876,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.ShowVcenterCredentials", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ShowVcenterCredentials", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ShowVcenterCredentials._get_response( self._host, @@ -8528,7 +11923,31 @@ def __call__( pb_resp = vmwareengine_resources.Credentials.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_show_vcenter_credentials(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.Credentials.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.show_vcenter_credentials", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ShowVcenterCredentials", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UndeletePrivateCloud( @@ -8566,7 +11985,7 @@ 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 private cloud method over HTTP. @@ -8577,8 +11996,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -8591,6 +12012,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUndeletePrivateCloud._get_http_options() ) + request, metadata = self._interceptor.pre_undelete_private_cloud( request, metadata ) @@ -8607,6 +12029,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.UndeletePrivateCloud", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UndeletePrivateCloud", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._UndeletePrivateCloud._get_response( self._host, @@ -8626,7 +12075,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_private_cloud(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.undelete_private_cloud", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UndeletePrivateCloud", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCluster( @@ -8664,7 +12135,7 @@ 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. @@ -8675,8 +12146,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -8689,6 +12162,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUpdateCluster._get_http_options() ) + request, metadata = self._interceptor.pre_update_cluster(request, metadata) transcoded_request = _BaseVmwareEngineRestTransport._BaseUpdateCluster._get_transcoded_request( http_options, request @@ -8703,6 +12177,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.UpdateCluster", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._UpdateCluster._get_response( self._host, @@ -8722,7 +12223,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.vmwareengine_v1.VmwareEngineClient.update_cluster", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDnsForwarding( @@ -8760,7 +12283,7 @@ 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 dns forwarding method over HTTP. @@ -8771,8 +12294,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -8785,6 +12310,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUpdateDnsForwarding._get_http_options() ) + request, metadata = self._interceptor.pre_update_dns_forwarding( request, metadata ) @@ -8801,6 +12327,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.UpdateDnsForwarding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateDnsForwarding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._UpdateDnsForwarding._get_response( self._host, @@ -8820,7 +12373,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_dns_forwarding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.update_dns_forwarding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateDnsForwarding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateExternalAccessRule( @@ -8859,7 +12434,7 @@ 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 external access rule method over HTTP. @@ -8871,8 +12446,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -8885,6 +12462,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUpdateExternalAccessRule._get_http_options() ) + request, metadata = self._interceptor.pre_update_external_access_rule( request, metadata ) @@ -8901,6 +12479,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.UpdateExternalAccessRule", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateExternalAccessRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._UpdateExternalAccessRule._get_response( @@ -8922,7 +12527,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_external_access_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.update_external_access_rule", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateExternalAccessRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateExternalAddress( @@ -8960,7 +12587,7 @@ 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 external address method over HTTP. @@ -8971,8 +12598,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -8985,6 +12614,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUpdateExternalAddress._get_http_options() ) + request, metadata = self._interceptor.pre_update_external_address( request, metadata ) @@ -9001,6 +12631,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.UpdateExternalAddress", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateExternalAddress", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._UpdateExternalAddress._get_response( self._host, @@ -9020,7 +12677,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_external_address(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.update_external_address", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateExternalAddress", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateLoggingServer( @@ -9058,7 +12737,7 @@ 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 logging server method over HTTP. @@ -9069,8 +12748,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -9083,6 +12764,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUpdateLoggingServer._get_http_options() ) + request, metadata = self._interceptor.pre_update_logging_server( request, metadata ) @@ -9099,6 +12781,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.UpdateLoggingServer", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateLoggingServer", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._UpdateLoggingServer._get_response( self._host, @@ -9118,7 +12827,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_logging_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.vmwareengine_v1.VmwareEngineClient.update_logging_server", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateLoggingServer", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateManagementDnsZoneBinding( @@ -9157,7 +12888,7 @@ 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 management dns zone binding method over HTTP. @@ -9169,8 +12900,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -9183,6 +12916,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUpdateManagementDnsZoneBinding._get_http_options() ) + ( request, metadata, @@ -9202,6 +12936,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.UpdateManagementDnsZoneBinding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateManagementDnsZoneBinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._UpdateManagementDnsZoneBinding._get_response( @@ -9223,7 +12984,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_management_dns_zone_binding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.update_management_dns_zone_binding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateManagementDnsZoneBinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateNetworkPeering( @@ -9261,7 +13044,7 @@ 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 network peering method over HTTP. @@ -9272,8 +13055,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -9286,6 +13071,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUpdateNetworkPeering._get_http_options() ) + request, metadata = self._interceptor.pre_update_network_peering( request, metadata ) @@ -9302,6 +13088,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.UpdateNetworkPeering", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateNetworkPeering", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._UpdateNetworkPeering._get_response( self._host, @@ -9321,7 +13134,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_network_peering(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.update_network_peering", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateNetworkPeering", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateNetworkPolicy( @@ -9359,7 +13194,7 @@ 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 network policy method over HTTP. @@ -9370,8 +13205,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -9384,6 +13221,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUpdateNetworkPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_update_network_policy( request, metadata ) @@ -9400,6 +13238,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.UpdateNetworkPolicy", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateNetworkPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._UpdateNetworkPolicy._get_response( self._host, @@ -9419,7 +13284,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_network_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.vmwareengine_v1.VmwareEngineClient.update_network_policy", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateNetworkPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdatePrivateCloud( @@ -9457,7 +13344,7 @@ 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 private cloud method over HTTP. @@ -9468,8 +13355,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -9482,6 +13371,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUpdatePrivateCloud._get_http_options() ) + request, metadata = self._interceptor.pre_update_private_cloud( request, metadata ) @@ -9498,6 +13388,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.UpdatePrivateCloud", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdatePrivateCloud", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._UpdatePrivateCloud._get_response( self._host, @@ -9517,7 +13434,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_private_cloud(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.update_private_cloud", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdatePrivateCloud", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdatePrivateConnection( @@ -9556,7 +13495,7 @@ 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 private connection method over HTTP. @@ -9567,8 +13506,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -9581,6 +13522,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUpdatePrivateConnection._get_http_options() ) + request, metadata = self._interceptor.pre_update_private_connection( request, metadata ) @@ -9597,6 +13539,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.UpdatePrivateConnection", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdatePrivateConnection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._UpdatePrivateConnection._get_response( self._host, @@ -9616,7 +13585,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_private_connection(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.update_private_connection", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdatePrivateConnection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSubnet( @@ -9654,7 +13645,7 @@ 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 subnet method over HTTP. @@ -9665,8 +13656,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -9679,6 +13672,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUpdateSubnet._get_http_options() ) + request, metadata = self._interceptor.pre_update_subnet(request, metadata) transcoded_request = _BaseVmwareEngineRestTransport._BaseUpdateSubnet._get_transcoded_request( http_options, request @@ -9697,6 +13691,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.UpdateSubnet", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateSubnet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._UpdateSubnet._get_response( self._host, @@ -9716,7 +13737,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_subnet(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.update_subnet", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateSubnet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateVmwareEngineNetwork( @@ -9755,7 +13798,7 @@ 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 vmware engine network method over HTTP. @@ -9767,8 +13810,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -9781,6 +13826,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUpdateVmwareEngineNetwork._get_http_options() ) + request, metadata = self._interceptor.pre_update_vmware_engine_network( request, metadata ) @@ -9797,6 +13843,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.UpdateVmwareEngineNetwork", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateVmwareEngineNetwork", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._UpdateVmwareEngineNetwork._get_response( @@ -9818,7 +13891,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_vmware_engine_network(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vmwareengine_v1.VmwareEngineClient.update_vmware_engine_network", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateVmwareEngineNetwork", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -10566,7 +14661,7 @@ 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. @@ -10576,8 +14671,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -10586,6 +14683,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseVmwareEngineRestTransport._BaseGetLocation._get_transcoded_request( @@ -10600,6 +14698,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.GetLocation", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetLocation._get_response( self._host, @@ -10619,6 +14744,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.vmwareengine_v1.VmwareEngineAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -10659,7 +14805,7 @@ 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. @@ -10669,8 +14815,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -10679,6 +14827,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseVmwareEngineRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -10689,6 +14838,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.ListLocations", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListLocations._get_response( self._host, @@ -10708,6 +14884,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.vmwareengine_v1.VmwareEngineAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -10748,7 +14945,7 @@ 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. @@ -10758,8 +14955,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -10768,6 +14967,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseVmwareEngineRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -10780,6 +14980,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetIamPolicy._get_response( self._host, @@ -10799,6 +15026,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.vmwareengine_v1.VmwareEngineAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -10840,7 +15088,7 @@ 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. @@ -10850,8 +15098,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -10860,6 +15110,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseVmwareEngineRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -10878,6 +15129,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._SetIamPolicy._get_response( self._host, @@ -10898,6 +15176,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.vmwareengine_v1.VmwareEngineAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -10939,7 +15238,7 @@ 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. @@ -10949,8 +15248,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -10959,6 +15260,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -10975,6 +15277,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._TestIamPermissions._get_response( self._host, @@ -10995,6 +15324,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.vmwareengine_v1.VmwareEngineAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -11035,7 +15385,7 @@ 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. @@ -11045,13 +15395,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 = ( _BaseVmwareEngineRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -11064,6 +15417,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._DeleteOperation._get_response( self._host, @@ -11119,7 +15499,7 @@ 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. @@ -11129,8 +15509,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -11139,6 +15521,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseVmwareEngineRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -11151,6 +15534,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.GetOperation", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetOperation._get_response( self._host, @@ -11170,6 +15580,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.vmwareengine_v1.VmwareEngineAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -11210,7 +15641,7 @@ 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. @@ -11220,8 +15651,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -11230,6 +15663,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseVmwareEngineRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -11240,6 +15674,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vmwareengine_v1.VmwareEngineClient.ListOperations", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListOperations._get_response( self._host, @@ -11259,6 +15720,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.vmwareengine_v1.VmwareEngineAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-vmwareengine/samples/generated_samples/snippet_metadata_google.cloud.vmwareengine.v1.json b/packages/google-cloud-vmwareengine/samples/generated_samples/snippet_metadata_google.cloud.vmwareengine.v1.json index 988355f12a51..6d234586a410 100644 --- a/packages/google-cloud-vmwareengine/samples/generated_samples/snippet_metadata_google.cloud.vmwareengine.v1.json +++ b/packages/google-cloud-vmwareengine/samples/generated_samples/snippet_metadata_google.cloud.vmwareengine.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-vmwareengine", - "version": "1.6.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", @@ -409,7 +409,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -497,7 +497,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -586,7 +586,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -674,7 +674,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -763,7 +763,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -851,7 +851,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -940,7 +940,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1028,7 +1028,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1117,7 +1117,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1205,7 +1205,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1294,7 +1294,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1382,7 +1382,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1471,7 +1471,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1559,7 +1559,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1648,7 +1648,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1736,7 +1736,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1825,7 +1825,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1913,7 +1913,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1994,7 +1994,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2074,7 +2074,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2155,7 +2155,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2235,7 +2235,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2316,7 +2316,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2396,7 +2396,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2477,7 +2477,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2557,7 +2557,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2638,7 +2638,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2718,7 +2718,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2799,7 +2799,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2879,7 +2879,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2960,7 +2960,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3040,7 +3040,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3121,7 +3121,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3201,7 +3201,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3282,7 +3282,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3362,7 +3362,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3443,7 +3443,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3523,7 +3523,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3604,7 +3604,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.FetchNetworkPolicyExternalAddressesAsyncPager", @@ -3684,7 +3684,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.FetchNetworkPolicyExternalAddressesPager", @@ -3765,7 +3765,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.Cluster", @@ -3845,7 +3845,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.Cluster", @@ -3926,7 +3926,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.DnsBindPermission", @@ -4006,7 +4006,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.DnsBindPermission", @@ -4087,7 +4087,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.DnsForwarding", @@ -4167,7 +4167,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.DnsForwarding", @@ -4248,7 +4248,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.ExternalAccessRule", @@ -4328,7 +4328,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.ExternalAccessRule", @@ -4409,7 +4409,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.ExternalAddress", @@ -4489,7 +4489,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.ExternalAddress", @@ -4570,7 +4570,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.HcxActivationKey", @@ -4650,7 +4650,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.HcxActivationKey", @@ -4731,7 +4731,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.LoggingServer", @@ -4811,7 +4811,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.LoggingServer", @@ -4892,7 +4892,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.ManagementDnsZoneBinding", @@ -4972,7 +4972,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.ManagementDnsZoneBinding", @@ -5053,7 +5053,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.NetworkPeering", @@ -5133,7 +5133,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.NetworkPeering", @@ -5214,7 +5214,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.NetworkPolicy", @@ -5294,7 +5294,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.NetworkPolicy", @@ -5375,7 +5375,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.NodeType", @@ -5455,7 +5455,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.NodeType", @@ -5536,7 +5536,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.Node", @@ -5616,7 +5616,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.Node", @@ -5697,7 +5697,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.PrivateCloud", @@ -5777,7 +5777,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.PrivateCloud", @@ -5858,7 +5858,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.PrivateConnection", @@ -5938,7 +5938,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.PrivateConnection", @@ -6019,7 +6019,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.Subnet", @@ -6099,7 +6099,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.Subnet", @@ -6180,7 +6180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.VmwareEngineNetwork", @@ -6260,7 +6260,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.VmwareEngineNetwork", @@ -6345,7 +6345,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6429,7 +6429,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6510,7 +6510,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListClustersAsyncPager", @@ -6590,7 +6590,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListClustersPager", @@ -6671,7 +6671,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListExternalAccessRulesAsyncPager", @@ -6751,7 +6751,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListExternalAccessRulesPager", @@ -6832,7 +6832,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListExternalAddressesAsyncPager", @@ -6912,7 +6912,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListExternalAddressesPager", @@ -6993,7 +6993,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListHcxActivationKeysAsyncPager", @@ -7073,7 +7073,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListHcxActivationKeysPager", @@ -7154,7 +7154,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListLoggingServersAsyncPager", @@ -7234,7 +7234,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListLoggingServersPager", @@ -7315,7 +7315,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListManagementDnsZoneBindingsAsyncPager", @@ -7395,7 +7395,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListManagementDnsZoneBindingsPager", @@ -7476,7 +7476,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNetworkPeeringsAsyncPager", @@ -7556,7 +7556,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNetworkPeeringsPager", @@ -7637,7 +7637,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNetworkPoliciesAsyncPager", @@ -7717,7 +7717,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNetworkPoliciesPager", @@ -7798,7 +7798,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNodeTypesAsyncPager", @@ -7878,7 +7878,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNodeTypesPager", @@ -7959,7 +7959,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNodesAsyncPager", @@ -8039,7 +8039,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNodesPager", @@ -8120,7 +8120,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPeeringRoutesAsyncPager", @@ -8200,7 +8200,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPeeringRoutesPager", @@ -8281,7 +8281,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPrivateCloudsAsyncPager", @@ -8361,7 +8361,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPrivateCloudsPager", @@ -8442,7 +8442,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPrivateConnectionPeeringRoutesAsyncPager", @@ -8522,7 +8522,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPrivateConnectionPeeringRoutesPager", @@ -8603,7 +8603,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPrivateConnectionsAsyncPager", @@ -8683,7 +8683,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPrivateConnectionsPager", @@ -8764,7 +8764,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListSubnetsAsyncPager", @@ -8844,7 +8844,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListSubnetsPager", @@ -8925,7 +8925,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListVmwareEngineNetworksAsyncPager", @@ -9005,7 +9005,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListVmwareEngineNetworksPager", @@ -9086,7 +9086,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9166,7 +9166,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9247,7 +9247,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9327,7 +9327,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9408,7 +9408,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9488,7 +9488,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9573,7 +9573,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9657,7 +9657,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9738,7 +9738,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.Credentials", @@ -9818,7 +9818,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.Credentials", @@ -9899,7 +9899,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.Credentials", @@ -9979,7 +9979,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.Credentials", @@ -10060,7 +10060,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -10140,7 +10140,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -10225,7 +10225,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -10309,7 +10309,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -10394,7 +10394,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -10478,7 +10478,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -10563,7 +10563,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -10647,7 +10647,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -10732,7 +10732,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -10816,7 +10816,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -10901,7 +10901,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -10985,7 +10985,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11070,7 +11070,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11154,7 +11154,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11239,7 +11239,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11323,7 +11323,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11408,7 +11408,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11492,7 +11492,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11577,7 +11577,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11661,7 +11661,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11746,7 +11746,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11830,7 +11830,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11915,7 +11915,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11999,7 +11999,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -12084,7 +12084,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -12168,7 +12168,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-vmwareengine/tests/unit/gapic/vmwareengine_v1/test_vmware_engine.py b/packages/google-cloud-vmwareengine/tests/unit/gapic/vmwareengine_v1/test_vmware_engine.py index c803626d8bd6..8ed7826f3a23 100644 --- a/packages/google-cloud-vmwareengine/tests/unit/gapic/vmwareengine_v1/test_vmware_engine.py +++ b/packages/google-cloud-vmwareengine/tests/unit/gapic/vmwareengine_v1/test_vmware_engine.py @@ -30931,6 +30931,7 @@ def test_list_private_clouds_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_private_clouds(request) @@ -30986,6 +30987,7 @@ def test_list_private_clouds_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_private_clouds(**mock_args) @@ -31182,6 +31184,7 @@ def test_get_private_cloud_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_private_cloud(request) @@ -31229,6 +31232,7 @@ def test_get_private_cloud_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_private_cloud(**mock_args) @@ -31381,6 +31385,7 @@ def test_create_private_cloud_rest_required_fields( response_value._content = json_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_private_cloud(request) @@ -31447,6 +31452,7 @@ def test_create_private_cloud_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_private_cloud(**mock_args) @@ -31588,6 +31594,7 @@ def test_update_private_cloud_rest_required_fields( response_value._content = json_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_private_cloud(request) @@ -31649,6 +31656,7 @@ def test_update_private_cloud_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_private_cloud(**mock_args) @@ -31794,6 +31802,7 @@ def test_delete_private_cloud_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_private_cloud(request) @@ -31848,6 +31857,7 @@ def test_delete_private_cloud_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_private_cloud(**mock_args) @@ -31986,6 +31996,7 @@ def test_undelete_private_cloud_rest_required_fields( response_value._content = json_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_private_cloud(request) @@ -32031,6 +32042,7 @@ def test_undelete_private_cloud_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_private_cloud(**mock_args) @@ -32171,6 +32183,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) @@ -32228,6 +32241,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) @@ -32420,6 +32434,7 @@ def test_get_cluster_rest_required_fields(request_type=vmwareengine.GetClusterRe response_value._content = json_return_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) @@ -32467,6 +32482,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) @@ -32615,6 +32631,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) @@ -32683,6 +32700,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) @@ -32821,6 +32839,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) @@ -32883,6 +32902,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) @@ -33018,6 +33038,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) @@ -33063,6 +33084,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) @@ -33199,6 +33221,7 @@ def test_list_nodes_rest_required_fields(request_type=vmwareengine.ListNodesRequ response_value._content = json_return_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) @@ -33254,6 +33277,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) @@ -33446,6 +33470,7 @@ def test_get_node_rest_required_fields(request_type=vmwareengine.GetNodeRequest) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_node(request) @@ -33493,6 +33518,7 @@ def test_get_node_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_node(**mock_args) @@ -33638,6 +33664,7 @@ def test_list_external_addresses_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_external_addresses(request) @@ -33695,6 +33722,7 @@ def test_list_external_addresses_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_external_addresses(**mock_args) @@ -33911,6 +33939,7 @@ def test_fetch_network_policy_external_addresses_rest_required_fields( response_value._content = json_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_network_policy_external_addresses(request) @@ -33970,6 +33999,7 @@ def test_fetch_network_policy_external_addresses_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.fetch_network_policy_external_addresses(**mock_args) @@ -34177,6 +34207,7 @@ def test_get_external_address_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_external_address(request) @@ -34224,6 +34255,7 @@ def test_get_external_address_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_external_address(**mock_args) @@ -34376,6 +34408,7 @@ def test_create_external_address_rest_required_fields( response_value._content = json_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_external_address(request) @@ -34443,6 +34476,7 @@ def test_create_external_address_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_external_address(**mock_args) @@ -34585,6 +34619,7 @@ def test_update_external_address_rest_required_fields( response_value._content = json_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_external_address(request) @@ -34646,6 +34681,7 @@ def test_update_external_address_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_external_address(**mock_args) @@ -34786,6 +34822,7 @@ def test_delete_external_address_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_external_address(request) @@ -34831,6 +34868,7 @@ def test_delete_external_address_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_external_address(**mock_args) @@ -34969,6 +35007,7 @@ def test_list_subnets_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_subnets(request) @@ -35024,6 +35063,7 @@ def test_list_subnets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_subnets(**mock_args) @@ -35216,6 +35256,7 @@ def test_get_subnet_rest_required_fields(request_type=vmwareengine.GetSubnetRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_subnet(request) @@ -35263,6 +35304,7 @@ def test_get_subnet_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_subnet(**mock_args) @@ -35393,6 +35435,7 @@ def test_update_subnet_rest_required_fields( response_value._content = json_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_subnet(request) @@ -35449,6 +35492,7 @@ def test_update_subnet_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_subnet(**mock_args) @@ -35595,6 +35639,7 @@ def test_list_external_access_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.list_external_access_rules(request) @@ -35652,6 +35697,7 @@ def test_list_external_access_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.list_external_access_rules(**mock_args) @@ -35855,6 +35901,7 @@ def test_get_external_access_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_external_access_rule(request) @@ -35902,6 +35949,7 @@ def test_get_external_access_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_external_access_rule(**mock_args) @@ -36057,6 +36105,7 @@ def test_create_external_access_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.create_external_access_rule(request) @@ -36126,6 +36175,7 @@ def test_create_external_access_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.create_external_access_rule(**mock_args) @@ -36270,6 +36320,7 @@ def test_update_external_access_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.update_external_access_rule(request) @@ -36333,6 +36384,7 @@ def test_update_external_access_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.update_external_access_rule(**mock_args) @@ -36475,6 +36527,7 @@ def test_delete_external_access_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.delete_external_access_rule(request) @@ -36520,6 +36573,7 @@ def test_delete_external_access_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.delete_external_access_rule(**mock_args) @@ -36664,6 +36718,7 @@ def test_list_logging_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_logging_servers(request) @@ -36721,6 +36776,7 @@ def test_list_logging_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_logging_servers(**mock_args) @@ -36921,6 +36977,7 @@ def test_get_logging_server_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_logging_server(request) @@ -36968,6 +37025,7 @@ def test_get_logging_server_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_logging_server(**mock_args) @@ -37120,6 +37178,7 @@ def test_create_logging_server_rest_required_fields( response_value._content = json_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_logging_server(request) @@ -37187,6 +37246,7 @@ def test_create_logging_server_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_logging_server(**mock_args) @@ -37329,6 +37389,7 @@ def test_update_logging_server_rest_required_fields( response_value._content = json_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_logging_server(request) @@ -37390,6 +37451,7 @@ def test_update_logging_server_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_logging_server(**mock_args) @@ -37530,6 +37592,7 @@ def test_delete_logging_server_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_logging_server(request) @@ -37575,6 +37638,7 @@ def test_delete_logging_server_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_logging_server(**mock_args) @@ -37714,6 +37778,7 @@ def test_list_node_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_node_types(request) @@ -37768,6 +37833,7 @@ def test_list_node_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_node_types(**mock_args) @@ -37961,6 +38027,7 @@ def test_get_node_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_node_type(request) @@ -38008,6 +38075,7 @@ def test_get_node_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_node_type(**mock_args) @@ -38142,6 +38210,7 @@ def test_show_nsx_credentials_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.show_nsx_credentials(request) @@ -38189,6 +38258,7 @@ def test_show_nsx_credentials_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.show_nsx_credentials(**mock_args) @@ -38327,6 +38397,7 @@ def test_show_vcenter_credentials_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.show_vcenter_credentials(request) @@ -38374,6 +38445,7 @@ def test_show_vcenter_credentials_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.show_vcenter_credentials(**mock_args) @@ -38512,6 +38584,7 @@ def test_reset_nsx_credentials_rest_required_fields( response_value._content = json_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_nsx_credentials(request) @@ -38557,6 +38630,7 @@ def test_reset_nsx_credentials_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_nsx_credentials(**mock_args) @@ -38695,6 +38769,7 @@ def test_reset_vcenter_credentials_rest_required_fields( response_value._content = json_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_vcenter_credentials(request) @@ -38740,6 +38815,7 @@ def test_reset_vcenter_credentials_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_vcenter_credentials(**mock_args) @@ -38875,6 +38951,7 @@ def test_get_dns_forwarding_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_dns_forwarding(request) @@ -38922,6 +38999,7 @@ def test_get_dns_forwarding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_dns_forwarding(**mock_args) @@ -39062,6 +39140,7 @@ def test_update_dns_forwarding_rest_required_fields( response_value._content = json_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_dns_forwarding(request) @@ -39123,6 +39202,7 @@ def test_update_dns_forwarding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_dns_forwarding(**mock_args) @@ -39259,6 +39339,7 @@ def test_get_network_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.get_network_peering(request) @@ -39306,6 +39387,7 @@ def test_get_network_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.get_network_peering(**mock_args) @@ -39451,6 +39533,7 @@ def test_list_network_peerings_rest_required_fields( response_value._content = json_return_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_peerings(request) @@ -39506,6 +39589,7 @@ def test_list_network_peerings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_peerings(**mock_args) @@ -39723,6 +39807,7 @@ def test_create_network_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.create_network_peering(request) @@ -39788,6 +39873,7 @@ def test_create_network_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.create_network_peering(**mock_args) @@ -39929,6 +40015,7 @@ def test_delete_network_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.delete_network_peering(request) @@ -39974,6 +40061,7 @@ def test_delete_network_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.delete_network_peering(**mock_args) @@ -40114,6 +40202,7 @@ def test_update_network_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_network_peering(request) @@ -40175,6 +40264,7 @@ def test_update_network_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_network_peering(**mock_args) @@ -40319,6 +40409,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) @@ -40375,6 +40466,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) @@ -40594,6 +40686,7 @@ def test_create_hcx_activation_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.create_hcx_activation_key(request) @@ -40663,6 +40756,7 @@ def test_create_hcx_activation_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.create_hcx_activation_key(**mock_args) @@ -40810,6 +40904,7 @@ def test_list_hcx_activation_keys_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_hcx_activation_keys(request) @@ -40865,6 +40960,7 @@ def test_list_hcx_activation_keys_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_hcx_activation_keys(**mock_args) @@ -41068,6 +41164,7 @@ def test_get_hcx_activation_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.get_hcx_activation_key(request) @@ -41115,6 +41212,7 @@ def test_get_hcx_activation_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.get_hcx_activation_key(**mock_args) @@ -41250,6 +41348,7 @@ def test_get_network_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_network_policy(request) @@ -41297,6 +41396,7 @@ def test_get_network_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_network_policy(**mock_args) @@ -41442,6 +41542,7 @@ def test_list_network_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.list_network_policies(request) @@ -41497,6 +41598,7 @@ def test_list_network_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.list_network_policies(**mock_args) @@ -41712,6 +41814,7 @@ def test_create_network_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.create_network_policy(request) @@ -41777,6 +41880,7 @@ def test_create_network_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.create_network_policy(**mock_args) @@ -41919,6 +42023,7 @@ def test_update_network_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.update_network_policy(request) @@ -41980,6 +42085,7 @@ def test_update_network_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.update_network_policy(**mock_args) @@ -42120,6 +42226,7 @@ def test_delete_network_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.delete_network_policy(request) @@ -42165,6 +42272,7 @@ def test_delete_network_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.delete_network_policy(**mock_args) @@ -42312,6 +42420,7 @@ def test_list_management_dns_zone_bindings_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_management_dns_zone_bindings(request) @@ -42373,6 +42482,7 @@ def test_list_management_dns_zone_bindings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_management_dns_zone_bindings(**mock_args) @@ -42584,6 +42694,7 @@ def test_get_management_dns_zone_binding_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_management_dns_zone_binding(request) @@ -42633,6 +42744,7 @@ def test_get_management_dns_zone_binding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_management_dns_zone_binding(**mock_args) @@ -42793,6 +42905,7 @@ def test_create_management_dns_zone_binding_rest_required_fields( response_value._content = json_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_management_dns_zone_binding(request) @@ -42864,6 +42977,7 @@ def test_create_management_dns_zone_binding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_management_dns_zone_binding(**mock_args) @@ -43010,6 +43124,7 @@ def test_update_management_dns_zone_binding_rest_required_fields( response_value._content = json_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_management_dns_zone_binding(request) @@ -43075,6 +43190,7 @@ def test_update_management_dns_zone_binding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_management_dns_zone_binding(**mock_args) @@ -43219,6 +43335,7 @@ def test_delete_management_dns_zone_binding_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_management_dns_zone_binding(request) @@ -43266,6 +43383,7 @@ def test_delete_management_dns_zone_binding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_management_dns_zone_binding(**mock_args) @@ -43406,6 +43524,7 @@ def test_repair_management_dns_zone_binding_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.repair_management_dns_zone_binding(request) @@ -43453,6 +43572,7 @@ def test_repair_management_dns_zone_binding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.repair_management_dns_zone_binding(**mock_args) @@ -43612,6 +43732,7 @@ def test_create_vmware_engine_network_rest_required_fields( response_value._content = json_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_vmware_engine_network(request) @@ -43679,6 +43800,7 @@ def test_create_vmware_engine_network_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_vmware_engine_network(**mock_args) @@ -43823,6 +43945,7 @@ def test_update_vmware_engine_network_rest_required_fields( response_value._content = json_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_vmware_engine_network(request) @@ -43886,6 +44009,7 @@ def test_update_vmware_engine_network_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_vmware_engine_network(**mock_args) @@ -44033,6 +44157,7 @@ def test_delete_vmware_engine_network_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_vmware_engine_network(request) @@ -44086,6 +44211,7 @@ def test_delete_vmware_engine_network_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_vmware_engine_network(**mock_args) @@ -44222,6 +44348,7 @@ def test_get_vmware_engine_network_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_vmware_engine_network(request) @@ -44269,6 +44396,7 @@ def test_get_vmware_engine_network_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_vmware_engine_network(**mock_args) @@ -44416,6 +44544,7 @@ def test_list_vmware_engine_networks_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_vmware_engine_networks(request) @@ -44471,6 +44600,7 @@ def test_list_vmware_engine_networks_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_vmware_engine_networks(**mock_args) @@ -44691,6 +44821,7 @@ def test_create_private_connection_rest_required_fields( response_value._content = json_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_private_connection(request) @@ -44758,6 +44889,7 @@ def test_create_private_connection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_private_connection(**mock_args) @@ -44898,6 +45030,7 @@ def test_get_private_connection_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_private_connection(request) @@ -44945,6 +45078,7 @@ def test_get_private_connection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_private_connection(**mock_args) @@ -45090,6 +45224,7 @@ def test_list_private_connections_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_private_connections(request) @@ -45145,6 +45280,7 @@ def test_list_private_connections_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_private_connections(**mock_args) @@ -45350,6 +45486,7 @@ def test_update_private_connection_rest_required_fields( response_value._content = json_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_private_connection(request) @@ -45413,6 +45550,7 @@ def test_update_private_connection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_private_connection(**mock_args) @@ -45555,6 +45693,7 @@ def test_delete_private_connection_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_private_connection(request) @@ -45600,6 +45739,7 @@ def test_delete_private_connection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_private_connection(**mock_args) @@ -45749,6 +45889,7 @@ def test_list_private_connection_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_private_connection_peering_routes(request) @@ -45808,6 +45949,7 @@ def test_list_private_connection_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_private_connection_peering_routes(**mock_args) @@ -46016,6 +46158,7 @@ def test_grant_dns_bind_permission_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.grant_dns_bind_permission(request) @@ -46070,6 +46213,7 @@ def test_grant_dns_bind_permission_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.grant_dns_bind_permission(**mock_args) @@ -46207,6 +46351,7 @@ def test_get_dns_bind_permission_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_dns_bind_permission(request) @@ -46254,6 +46399,7 @@ def test_get_dns_bind_permission_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_dns_bind_permission(**mock_args) @@ -46392,6 +46538,7 @@ def test_revoke_dns_bind_permission_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.revoke_dns_bind_permission(request) @@ -46446,6 +46593,7 @@ def test_revoke_dns_bind_permission_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.revoke_dns_bind_permission(**mock_args) @@ -50448,6 +50596,7 @@ def test_list_private_clouds_rest_bad_request( response_value.status_code = 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_private_clouds(request) @@ -50484,6 +50633,7 @@ def test_list_private_clouds_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_private_clouds(request) # Establish that the response is the type that we expect. @@ -50525,6 +50675,7 @@ def test_list_private_clouds_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmwareengine.ListPrivateCloudsResponse.to_json( vmwareengine.ListPrivateCloudsResponse() ) @@ -50571,6 +50722,7 @@ def test_get_private_cloud_rest_bad_request( response_value.status_code = 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_private_cloud(request) @@ -50610,6 +50762,7 @@ def test_get_private_cloud_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_private_cloud(request) # Establish that the response is the type that we expect. @@ -50654,6 +50807,7 @@ def test_get_private_cloud_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmwareengine_resources.PrivateCloud.to_json( vmwareengine_resources.PrivateCloud() ) @@ -50700,6 +50854,7 @@ def test_create_private_cloud_rest_bad_request( response_value.status_code = 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_private_cloud(request) @@ -50841,6 +50996,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_private_cloud(request) # Establish that the response is the type that we expect. @@ -50882,6 +51038,7 @@ def test_create_private_cloud_rest_interceptors(null_interceptor): req.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 @@ -50930,6 +51087,7 @@ def test_update_private_cloud_rest_bad_request( response_value.status_code = 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_private_cloud(request) @@ -51075,6 +51233,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_private_cloud(request) # Establish that the response is the type that we expect. @@ -51116,6 +51275,7 @@ def test_update_private_cloud_rest_interceptors(null_interceptor): req.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 @@ -51160,6 +51320,7 @@ def test_delete_private_cloud_rest_bad_request( response_value.status_code = 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_private_cloud(request) @@ -51190,6 +51351,7 @@ def test_delete_private_cloud_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_private_cloud(request) # Establish that the response is the type that we expect. @@ -51231,6 +51393,7 @@ def test_delete_private_cloud_rest_interceptors(null_interceptor): req.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 @@ -51275,6 +51438,7 @@ def test_undelete_private_cloud_rest_bad_request( response_value.status_code = 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_private_cloud(request) @@ -51305,6 +51469,7 @@ def test_undelete_private_cloud_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_private_cloud(request) # Establish that the response is the type that we expect. @@ -51346,6 +51511,7 @@ def test_undelete_private_cloud_rest_interceptors(null_interceptor): req.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 @@ -51390,6 +51556,7 @@ def test_list_clusters_rest_bad_request(request_type=vmwareengine.ListClustersRe response_value.status_code = 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) @@ -51428,6 +51595,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. @@ -51469,6 +51637,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 = vmwareengine.ListClustersResponse.to_json( vmwareengine.ListClustersResponse() ) @@ -51515,6 +51684,7 @@ def test_get_cluster_rest_bad_request(request_type=vmwareengine.GetClusterReques response_value.status_code = 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) @@ -51555,6 +51725,7 @@ 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. @@ -51596,6 +51767,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 = vmwareengine_resources.Cluster.to_json( vmwareengine_resources.Cluster() ) @@ -51644,6 +51816,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) @@ -51762,6 +51935,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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. @@ -51803,6 +51977,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 @@ -51851,6 +52026,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) @@ -51971,6 +52147,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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. @@ -52012,6 +52189,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 @@ -52058,6 +52236,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) @@ -52090,6 +52269,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. @@ -52131,6 +52311,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 @@ -52175,6 +52356,7 @@ def test_list_nodes_rest_bad_request(request_type=vmwareengine.ListNodesRequest) response_value.status_code = 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) @@ -52212,6 +52394,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. @@ -52250,6 +52433,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 = vmwareengine.ListNodesResponse.to_json( vmwareengine.ListNodesResponse() ) @@ -52296,6 +52480,7 @@ def test_get_node_rest_bad_request(request_type=vmwareengine.GetNodeRequest): response_value.status_code = 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_node(request) @@ -52339,6 +52524,7 @@ def test_get_node_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_node(request) # Establish that the response is the type that we expect. @@ -52383,6 +52569,7 @@ def test_get_node_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmwareengine_resources.Node.to_json( vmwareengine_resources.Node() ) @@ -52431,6 +52618,7 @@ def test_list_external_addresses_rest_bad_request( response_value.status_code = 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_external_addresses(request) @@ -52469,6 +52657,7 @@ def test_list_external_addresses_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_external_addresses(request) # Establish that the response is the type that we expect. @@ -52510,6 +52699,7 @@ def test_list_external_addresses_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmwareengine.ListExternalAddressesResponse.to_json( vmwareengine.ListExternalAddressesResponse() ) @@ -52558,6 +52748,7 @@ def test_fetch_network_policy_external_addresses_rest_bad_request( response_value.status_code = 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_network_policy_external_addresses(request) @@ -52597,6 +52788,7 @@ def test_fetch_network_policy_external_addresses_rest_call_success(request_type) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_network_policy_external_addresses(request) # Establish that the response is the type that we expect. @@ -52639,6 +52831,7 @@ def test_fetch_network_policy_external_addresses_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 = vmwareengine.FetchNetworkPolicyExternalAddressesResponse.to_json( vmwareengine.FetchNetworkPolicyExternalAddressesResponse() ) @@ -52687,6 +52880,7 @@ def test_get_external_address_rest_bad_request( response_value.status_code = 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_external_address(request) @@ -52729,6 +52923,7 @@ def test_get_external_address_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_external_address(request) # Establish that the response is the type that we expect. @@ -52774,6 +52969,7 @@ def test_get_external_address_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmwareengine_resources.ExternalAddress.to_json( vmwareengine_resources.ExternalAddress() ) @@ -52822,6 +53018,7 @@ def test_create_external_address_rest_bad_request( response_value.status_code = 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_external_address(request) @@ -52933,6 +53130,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_external_address(request) # Establish that the response is the type that we expect. @@ -52974,6 +53172,7 @@ def test_create_external_address_rest_interceptors(null_interceptor): req.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 @@ -53022,6 +53221,7 @@ def test_update_external_address_rest_bad_request( response_value.status_code = 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_external_address(request) @@ -53135,6 +53335,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_external_address(request) # Establish that the response is the type that we expect. @@ -53176,6 +53377,7 @@ def test_update_external_address_rest_interceptors(null_interceptor): req.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 @@ -53222,6 +53424,7 @@ def test_delete_external_address_rest_bad_request( response_value.status_code = 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_external_address(request) @@ -53254,6 +53457,7 @@ def test_delete_external_address_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_external_address(request) # Establish that the response is the type that we expect. @@ -53295,6 +53499,7 @@ def test_delete_external_address_rest_interceptors(null_interceptor): req.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 @@ -53339,6 +53544,7 @@ def test_list_subnets_rest_bad_request(request_type=vmwareengine.ListSubnetsRequ response_value.status_code = 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_subnets(request) @@ -53377,6 +53583,7 @@ def test_list_subnets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_subnets(request) # Establish that the response is the type that we expect. @@ -53418,6 +53625,7 @@ def test_list_subnets_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmwareengine.ListSubnetsResponse.to_json( vmwareengine.ListSubnetsResponse() ) @@ -53464,6 +53672,7 @@ def test_get_subnet_rest_bad_request(request_type=vmwareengine.GetSubnetRequest) response_value.status_code = 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_subnet(request) @@ -53506,6 +53715,7 @@ def test_get_subnet_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_subnet(request) # Establish that the response is the type that we expect. @@ -53549,6 +53759,7 @@ def test_get_subnet_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmwareengine_resources.Subnet.to_json( vmwareengine_resources.Subnet() ) @@ -53597,6 +53808,7 @@ def test_update_subnet_rest_bad_request(request_type=vmwareengine.UpdateSubnetRe response_value.status_code = 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_subnet(request) @@ -53706,6 +53918,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_subnet(request) # Establish that the response is the type that we expect. @@ -53747,6 +53960,7 @@ def test_update_subnet_rest_interceptors(null_interceptor): req.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 @@ -53793,6 +54007,7 @@ def test_list_external_access_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.list_external_access_rules(request) @@ -53831,6 +54046,7 @@ def test_list_external_access_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.list_external_access_rules(request) # Establish that the response is the type that we expect. @@ -53872,6 +54088,7 @@ def test_list_external_access_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 = vmwareengine.ListExternalAccessRulesResponse.to_json( vmwareengine.ListExternalAccessRulesResponse() ) @@ -53920,6 +54137,7 @@ def test_get_external_access_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_external_access_rule(request) @@ -53965,6 +54183,7 @@ def test_get_external_access_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_external_access_rule(request) # Establish that the response is the type that we expect. @@ -54013,6 +54232,7 @@ def test_get_external_access_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 = vmwareengine_resources.ExternalAccessRule.to_json( vmwareengine_resources.ExternalAccessRule() ) @@ -54061,6 +54281,7 @@ def test_create_external_access_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.create_external_access_rule(request) @@ -54185,6 +54406,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_external_access_rule(request) # Establish that the response is the type that we expect. @@ -54226,6 +54448,7 @@ def test_create_external_access_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -54274,6 +54497,7 @@ def test_update_external_access_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.update_external_access_rule(request) @@ -54400,6 +54624,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_external_access_rule(request) # Establish that the response is the type that we expect. @@ -54441,6 +54666,7 @@ def test_update_external_access_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -54487,6 +54713,7 @@ def test_delete_external_access_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.delete_external_access_rule(request) @@ -54519,6 +54746,7 @@ def test_delete_external_access_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.delete_external_access_rule(request) # Establish that the response is the type that we expect. @@ -54560,6 +54788,7 @@ def test_delete_external_access_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -54606,6 +54835,7 @@ def test_list_logging_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_logging_servers(request) @@ -54644,6 +54874,7 @@ def test_list_logging_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_logging_servers(request) # Establish that the response is the type that we expect. @@ -54685,6 +54916,7 @@ def test_list_logging_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 = vmwareengine.ListLoggingServersResponse.to_json( vmwareengine.ListLoggingServersResponse() ) @@ -54733,6 +54965,7 @@ def test_get_logging_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.get_logging_server(request) @@ -54775,6 +55008,7 @@ def test_get_logging_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.get_logging_server(request) # Establish that the response is the type that we expect. @@ -54820,6 +55054,7 @@ def test_get_logging_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 = vmwareengine_resources.LoggingServer.to_json( vmwareengine_resources.LoggingServer() ) @@ -54868,6 +55103,7 @@ def test_create_logging_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.create_logging_server(request) @@ -54977,6 +55213,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_logging_server(request) # Establish that the response is the type that we expect. @@ -55018,6 +55255,7 @@ def test_create_logging_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 @@ -55066,6 +55304,7 @@ def test_update_logging_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.update_logging_server(request) @@ -55177,6 +55416,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_logging_server(request) # Establish that the response is the type that we expect. @@ -55218,6 +55458,7 @@ def test_update_logging_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 @@ -55264,6 +55505,7 @@ def test_delete_logging_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.delete_logging_server(request) @@ -55296,6 +55538,7 @@ def test_delete_logging_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.delete_logging_server(request) # Establish that the response is the type that we expect. @@ -55337,6 +55580,7 @@ def test_delete_logging_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 @@ -55381,6 +55625,7 @@ def test_list_node_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_node_types(request) @@ -55417,6 +55662,7 @@ def test_list_node_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_node_types(request) # Establish that the response is the type that we expect. @@ -55458,6 +55704,7 @@ def test_list_node_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 = vmwareengine.ListNodeTypesResponse.to_json( vmwareengine.ListNodeTypesResponse() ) @@ -55502,6 +55749,7 @@ def test_get_node_type_rest_bad_request(request_type=vmwareengine.GetNodeTypeReq response_value.status_code = 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_node_type(request) @@ -55549,6 +55797,7 @@ def test_get_node_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_node_type(request) # Establish that the response is the type that we expect. @@ -55601,6 +55850,7 @@ def test_get_node_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 = vmwareengine_resources.NodeType.to_json( vmwareengine_resources.NodeType() ) @@ -55649,6 +55899,7 @@ def test_show_nsx_credentials_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.show_nsx_credentials(request) @@ -55687,6 +55938,7 @@ def test_show_nsx_credentials_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.show_nsx_credentials(request) # Establish that the response is the type that we expect. @@ -55728,6 +55980,7 @@ def test_show_nsx_credentials_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmwareengine_resources.Credentials.to_json( vmwareengine_resources.Credentials() ) @@ -55776,6 +56029,7 @@ def test_show_vcenter_credentials_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.show_vcenter_credentials(request) @@ -55814,6 +56068,7 @@ def test_show_vcenter_credentials_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.show_vcenter_credentials(request) # Establish that the response is the type that we expect. @@ -55855,6 +56110,7 @@ def test_show_vcenter_credentials_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmwareengine_resources.Credentials.to_json( vmwareengine_resources.Credentials() ) @@ -55903,6 +56159,7 @@ def test_reset_nsx_credentials_rest_bad_request( response_value.status_code = 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_nsx_credentials(request) @@ -55935,6 +56192,7 @@ def test_reset_nsx_credentials_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_nsx_credentials(request) # Establish that the response is the type that we expect. @@ -55976,6 +56234,7 @@ def test_reset_nsx_credentials_rest_interceptors(null_interceptor): req.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 @@ -56022,6 +56281,7 @@ def test_reset_vcenter_credentials_rest_bad_request( response_value.status_code = 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_vcenter_credentials(request) @@ -56054,6 +56314,7 @@ def test_reset_vcenter_credentials_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_vcenter_credentials(request) # Establish that the response is the type that we expect. @@ -56095,6 +56356,7 @@ def test_reset_vcenter_credentials_rest_interceptors(null_interceptor): req.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 @@ -56141,6 +56403,7 @@ def test_get_dns_forwarding_rest_bad_request( response_value.status_code = 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_dns_forwarding(request) @@ -56178,6 +56441,7 @@ def test_get_dns_forwarding_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_dns_forwarding(request) # Establish that the response is the type that we expect. @@ -56218,6 +56482,7 @@ def test_get_dns_forwarding_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmwareengine_resources.DnsForwarding.to_json( vmwareengine_resources.DnsForwarding() ) @@ -56268,6 +56533,7 @@ def test_update_dns_forwarding_rest_bad_request( response_value.status_code = 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_dns_forwarding(request) @@ -56380,6 +56646,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_dns_forwarding(request) # Establish that the response is the type that we expect. @@ -56421,6 +56688,7 @@ def test_update_dns_forwarding_rest_interceptors(null_interceptor): req.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 @@ -56467,6 +56735,7 @@ def test_get_network_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.get_network_peering(request) @@ -56517,6 +56786,7 @@ def test_get_network_peering_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_network_peering(request) # Establish that the response is the type that we expect. @@ -56573,6 +56843,7 @@ def test_get_network_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 = vmwareengine_resources.NetworkPeering.to_json( vmwareengine_resources.NetworkPeering() ) @@ -56619,6 +56890,7 @@ def test_list_network_peerings_rest_bad_request( response_value.status_code = 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_peerings(request) @@ -56655,6 +56927,7 @@ def test_list_network_peerings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_peerings(request) # Establish that the response is the type that we expect. @@ -56696,6 +56969,7 @@ def test_list_network_peerings_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmwareengine.ListNetworkPeeringsResponse.to_json( vmwareengine.ListNetworkPeeringsResponse() ) @@ -56742,6 +57016,7 @@ def test_create_network_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.create_network_peering(request) @@ -56857,6 +57132,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_network_peering(request) # Establish that the response is the type that we expect. @@ -56898,6 +57174,7 @@ def test_create_network_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -56944,6 +57221,7 @@ def test_delete_network_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.delete_network_peering(request) @@ -56976,6 +57254,7 @@ def test_delete_network_peering_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_network_peering(request) # Establish that the response is the type that we expect. @@ -57017,6 +57296,7 @@ def test_delete_network_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -57065,6 +57345,7 @@ def test_update_network_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_network_peering(request) @@ -57184,6 +57465,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_peering(request) # Establish that the response is the type that we expect. @@ -57225,6 +57507,7 @@ def test_update_network_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -57271,6 +57554,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) @@ -57308,6 +57592,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. @@ -57348,6 +57633,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 = vmwareengine.ListPeeringRoutesResponse.to_json( vmwareengine.ListPeeringRoutesResponse() ) @@ -57396,6 +57682,7 @@ def test_create_hcx_activation_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.create_hcx_activation_key(request) @@ -57504,6 +57791,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_hcx_activation_key(request) # Establish that the response is the type that we expect. @@ -57545,6 +57833,7 @@ def test_create_hcx_activation_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -57591,6 +57880,7 @@ def test_list_hcx_activation_keys_rest_bad_request( response_value.status_code = 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_hcx_activation_keys(request) @@ -57629,6 +57919,7 @@ def test_list_hcx_activation_keys_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_hcx_activation_keys(request) # Establish that the response is the type that we expect. @@ -57670,6 +57961,7 @@ def test_list_hcx_activation_keys_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmwareengine.ListHcxActivationKeysResponse.to_json( vmwareengine.ListHcxActivationKeysResponse() ) @@ -57718,6 +58010,7 @@ def test_get_hcx_activation_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.get_hcx_activation_key(request) @@ -57758,6 +58051,7 @@ def test_get_hcx_activation_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.get_hcx_activation_key(request) # Establish that the response is the type that we expect. @@ -57801,6 +58095,7 @@ def test_get_hcx_activation_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 = vmwareengine_resources.HcxActivationKey.to_json( vmwareengine_resources.HcxActivationKey() ) @@ -57849,6 +58144,7 @@ def test_get_network_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_network_policy(request) @@ -57891,6 +58187,7 @@ def test_get_network_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_network_policy(request) # Establish that the response is the type that we expect. @@ -57939,6 +58236,7 @@ def test_get_network_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 = vmwareengine_resources.NetworkPolicy.to_json( vmwareengine_resources.NetworkPolicy() ) @@ -57985,6 +58283,7 @@ def test_list_network_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.list_network_policies(request) @@ -58021,6 +58320,7 @@ def test_list_network_policies_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_policies(request) # Establish that the response is the type that we expect. @@ -58062,6 +58362,7 @@ def test_list_network_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 = vmwareengine.ListNetworkPoliciesResponse.to_json( vmwareengine.ListNetworkPoliciesResponse() ) @@ -58108,6 +58409,7 @@ def test_create_network_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.create_network_policy(request) @@ -58217,6 +58519,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_network_policy(request) # Establish that the response is the type that we expect. @@ -58258,6 +58561,7 @@ def test_create_network_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -58306,6 +58610,7 @@ def test_update_network_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.update_network_policy(request) @@ -58419,6 +58724,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_policy(request) # Establish that the response is the type that we expect. @@ -58460,6 +58766,7 @@ def test_update_network_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -58506,6 +58813,7 @@ def test_delete_network_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.delete_network_policy(request) @@ -58538,6 +58846,7 @@ def test_delete_network_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.delete_network_policy(request) # Establish that the response is the type that we expect. @@ -58579,6 +58888,7 @@ def test_delete_network_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -58625,6 +58935,7 @@ def test_list_management_dns_zone_bindings_rest_bad_request( response_value.status_code = 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_management_dns_zone_bindings(request) @@ -58665,6 +58976,7 @@ def test_list_management_dns_zone_bindings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_management_dns_zone_bindings(request) # Establish that the response is the type that we expect. @@ -58706,6 +59018,7 @@ def test_list_management_dns_zone_bindings_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmwareengine.ListManagementDnsZoneBindingsResponse.to_json( vmwareengine.ListManagementDnsZoneBindingsResponse() ) @@ -58754,6 +59067,7 @@ def test_get_management_dns_zone_binding_rest_bad_request( response_value.status_code = 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_management_dns_zone_binding(request) @@ -58795,6 +59109,7 @@ def test_get_management_dns_zone_binding_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_management_dns_zone_binding(request) # Establish that the response is the type that we expect. @@ -58840,6 +59155,7 @@ def test_get_management_dns_zone_binding_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmwareengine_resources.ManagementDnsZoneBinding.to_json( vmwareengine_resources.ManagementDnsZoneBinding() ) @@ -58888,6 +59204,7 @@ def test_create_management_dns_zone_binding_rest_bad_request( response_value.status_code = 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_management_dns_zone_binding(request) @@ -59003,6 +59320,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_management_dns_zone_binding(request) # Establish that the response is the type that we expect. @@ -59045,6 +59363,7 @@ def test_create_management_dns_zone_binding_rest_interceptors(null_interceptor): req.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 @@ -59093,6 +59412,7 @@ def test_update_management_dns_zone_binding_rest_bad_request( response_value.status_code = 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_management_dns_zone_binding(request) @@ -59210,6 +59530,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_management_dns_zone_binding(request) # Establish that the response is the type that we expect. @@ -59252,6 +59573,7 @@ def test_update_management_dns_zone_binding_rest_interceptors(null_interceptor): req.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 @@ -59298,6 +59620,7 @@ def test_delete_management_dns_zone_binding_rest_bad_request( response_value.status_code = 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_management_dns_zone_binding(request) @@ -59330,6 +59653,7 @@ def test_delete_management_dns_zone_binding_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_management_dns_zone_binding(request) # Establish that the response is the type that we expect. @@ -59372,6 +59696,7 @@ def test_delete_management_dns_zone_binding_rest_interceptors(null_interceptor): req.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 @@ -59418,6 +59743,7 @@ def test_repair_management_dns_zone_binding_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.repair_management_dns_zone_binding(request) @@ -59450,6 +59776,7 @@ def test_repair_management_dns_zone_binding_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.repair_management_dns_zone_binding(request) # Establish that the response is the type that we expect. @@ -59492,6 +59819,7 @@ def test_repair_management_dns_zone_binding_rest_interceptors(null_interceptor): req.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 @@ -59536,6 +59864,7 @@ def test_create_vmware_engine_network_rest_bad_request( response_value.status_code = 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_vmware_engine_network(request) @@ -59648,6 +59977,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_vmware_engine_network(request) # Establish that the response is the type that we expect. @@ -59689,6 +60019,7 @@ def test_create_vmware_engine_network_rest_interceptors(null_interceptor): req.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 @@ -59737,6 +60068,7 @@ def test_update_vmware_engine_network_rest_bad_request( response_value.status_code = 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_vmware_engine_network(request) @@ -59853,6 +60185,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_vmware_engine_network(request) # Establish that the response is the type that we expect. @@ -59894,6 +60227,7 @@ def test_update_vmware_engine_network_rest_interceptors(null_interceptor): req.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 @@ -59940,6 +60274,7 @@ def test_delete_vmware_engine_network_rest_bad_request( response_value.status_code = 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_vmware_engine_network(request) @@ -59972,6 +60307,7 @@ def test_delete_vmware_engine_network_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_vmware_engine_network(request) # Establish that the response is the type that we expect. @@ -60013,6 +60349,7 @@ def test_delete_vmware_engine_network_rest_interceptors(null_interceptor): req.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 @@ -60059,6 +60396,7 @@ def test_get_vmware_engine_network_rest_bad_request( response_value.status_code = 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_vmware_engine_network(request) @@ -60101,6 +60439,7 @@ def test_get_vmware_engine_network_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_vmware_engine_network(request) # Establish that the response is the type that we expect. @@ -60146,6 +60485,7 @@ def test_get_vmware_engine_network_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmwareengine_resources.VmwareEngineNetwork.to_json( vmwareengine_resources.VmwareEngineNetwork() ) @@ -60192,6 +60532,7 @@ def test_list_vmware_engine_networks_rest_bad_request( response_value.status_code = 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_vmware_engine_networks(request) @@ -60228,6 +60569,7 @@ def test_list_vmware_engine_networks_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_vmware_engine_networks(request) # Establish that the response is the type that we expect. @@ -60269,6 +60611,7 @@ def test_list_vmware_engine_networks_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmwareengine.ListVmwareEngineNetworksResponse.to_json( vmwareengine.ListVmwareEngineNetworksResponse() ) @@ -60315,6 +60658,7 @@ def test_create_private_connection_rest_bad_request( response_value.status_code = 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_private_connection(request) @@ -60429,6 +60773,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_private_connection(request) # Establish that the response is the type that we expect. @@ -60470,6 +60815,7 @@ def test_create_private_connection_rest_interceptors(null_interceptor): req.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 @@ -60516,6 +60862,7 @@ def test_get_private_connection_rest_bad_request( response_value.status_code = 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_private_connection(request) @@ -60563,6 +60910,7 @@ def test_get_private_connection_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_private_connection(request) # Establish that the response is the type that we expect. @@ -60625,6 +60973,7 @@ def test_get_private_connection_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmwareengine_resources.PrivateConnection.to_json( vmwareengine_resources.PrivateConnection() ) @@ -60671,6 +61020,7 @@ def test_list_private_connections_rest_bad_request( response_value.status_code = 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_private_connections(request) @@ -60707,6 +61057,7 @@ def test_list_private_connections_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_private_connections(request) # Establish that the response is the type that we expect. @@ -60748,6 +61099,7 @@ def test_list_private_connections_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmwareengine.ListPrivateConnectionsResponse.to_json( vmwareengine.ListPrivateConnectionsResponse() ) @@ -60798,6 +61150,7 @@ def test_update_private_connection_rest_bad_request( response_value.status_code = 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_private_connection(request) @@ -60916,6 +61269,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_private_connection(request) # Establish that the response is the type that we expect. @@ -60957,6 +61311,7 @@ def test_update_private_connection_rest_interceptors(null_interceptor): req.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 @@ -61003,6 +61358,7 @@ def test_delete_private_connection_rest_bad_request( response_value.status_code = 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_private_connection(request) @@ -61035,6 +61391,7 @@ def test_delete_private_connection_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_private_connection(request) # Establish that the response is the type that we expect. @@ -61076,6 +61433,7 @@ def test_delete_private_connection_rest_interceptors(null_interceptor): req.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 @@ -61122,6 +61480,7 @@ def test_list_private_connection_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_private_connection_peering_routes(request) @@ -61161,6 +61520,7 @@ def test_list_private_connection_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_private_connection_peering_routes(request) # Establish that the response is the type that we expect. @@ -61203,6 +61563,7 @@ def test_list_private_connection_peering_routes_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 = vmwareengine.ListPrivateConnectionPeeringRoutesResponse.to_json( vmwareengine.ListPrivateConnectionPeeringRoutesResponse() ) @@ -61249,6 +61610,7 @@ def test_grant_dns_bind_permission_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.grant_dns_bind_permission(request) @@ -61279,6 +61641,7 @@ def test_grant_dns_bind_permission_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.grant_dns_bind_permission(request) # Establish that the response is the type that we expect. @@ -61320,6 +61683,7 @@ def test_grant_dns_bind_permission_rest_interceptors(null_interceptor): req.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 @@ -61364,6 +61728,7 @@ def test_get_dns_bind_permission_rest_bad_request( response_value.status_code = 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_dns_bind_permission(request) @@ -61399,6 +61764,7 @@ def test_get_dns_bind_permission_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_dns_bind_permission(request) # Establish that the response is the type that we expect. @@ -61439,6 +61805,7 @@ def test_get_dns_bind_permission_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vmwareengine_resources.DnsBindPermission.to_json( vmwareengine_resources.DnsBindPermission() ) @@ -61485,6 +61852,7 @@ def test_revoke_dns_bind_permission_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.revoke_dns_bind_permission(request) @@ -61515,6 +61883,7 @@ def test_revoke_dns_bind_permission_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.revoke_dns_bind_permission(request) # Establish that the response is the type that we expect. @@ -61556,6 +61925,7 @@ def test_revoke_dns_bind_permission_rest_interceptors(null_interceptor): req.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 @@ -61600,6 +61970,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) @@ -61630,6 +62001,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) @@ -61658,6 +62030,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) @@ -61688,6 +62061,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) @@ -61719,6 +62093,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) @@ -61751,6 +62126,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) @@ -61782,6 +62158,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) @@ -61814,6 +62191,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) @@ -61845,6 +62223,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) @@ -61877,6 +62256,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) @@ -61907,6 +62287,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) @@ -61937,6 +62318,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) @@ -61967,6 +62349,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) @@ -61997,6 +62380,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) @@ -62027,6 +62411,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) @@ -62057,6 +62442,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-vpc-access/google/cloud/vpcaccess/gapic_version.py b/packages/google-cloud-vpc-access/google/cloud/vpcaccess/gapic_version.py index b50cada0b7ee..558c8aab67c5 100644 --- a/packages/google-cloud-vpc-access/google/cloud/vpcaccess/gapic_version.py +++ b/packages/google-cloud-vpc-access/google/cloud/vpcaccess/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.11.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/gapic_version.py b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/gapic_version.py index b50cada0b7ee..558c8aab67c5 100644 --- a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/gapic_version.py +++ b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_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.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/async_client.py b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/async_client.py index 505f41457a49..87301fecf313 100644 --- a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/async_client.py +++ b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_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, @@ -55,6 +56,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, VpcAccessServiceTransport from .transports.grpc_asyncio import VpcAccessServiceGrpcAsyncIOTransport +try: + from google.api_core import client_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 VpcAccessServiceAsyncClient: """Serverless VPC Access API allows users to create and manage @@ -265,6 +275,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.vpcaccess_v1.VpcAccessServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "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.vpcaccess.v1.VpcAccessService", + "credentialsType": None, + }, + ) + async def create_connector( self, request: Optional[Union[vpc_access.CreateConnectorRequest, dict]] = None, @@ -274,7 +306,7 @@ async def create_connector( connector: Optional[vpc_access.Connector] = None, retry: OptionalRetry = gapic_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 Serverless VPC Access connector, returns an operation. @@ -337,8 +369,10 @@ async def sample_create_connector(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -414,7 +448,7 @@ async def get_connector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vpc_access.Connector: r"""Gets a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist. @@ -459,8 +493,10 @@ async def sample_get_connector(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vpcaccess_v1.types.Connector: @@ -521,7 +557,7 @@ async def list_connectors( 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.ListConnectorsAsyncPager: r"""Lists Serverless VPC Access connectors. @@ -566,8 +602,10 @@ async def sample_list_connectors(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vpcaccess_v1.services.vpc_access_service.pagers.ListConnectorsAsyncPager: @@ -642,7 +680,7 @@ async def delete_connector( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist. @@ -691,8 +729,10 @@ async def sample_delete_connector(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -770,7 +810,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. @@ -781,8 +821,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. @@ -823,7 +865,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. @@ -834,8 +876,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. @@ -876,7 +920,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. @@ -887,8 +931,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-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/client.py b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/client.py index d286c651fa58..8a80f3ef1064 100644 --- a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/client.py +++ b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_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.vpcaccess_v1.VpcAccessServiceClient`.", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "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.vpcaccess.v1.VpcAccessService", + "credentialsType": None, + }, + ) + def create_connector( self, request: Optional[Union[vpc_access.CreateConnectorRequest, dict]] = None, @@ -664,7 +701,7 @@ def create_connector( connector: Optional[vpc_access.Connector] = None, retry: OptionalRetry = gapic_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 Serverless VPC Access connector, returns an operation. @@ -727,8 +764,10 @@ def sample_create_connector(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -801,7 +840,7 @@ def get_connector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vpc_access.Connector: r"""Gets a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist. @@ -846,8 +885,10 @@ def sample_get_connector(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vpcaccess_v1.types.Connector: @@ -905,7 +946,7 @@ def list_connectors( 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.ListConnectorsPager: r"""Lists Serverless VPC Access connectors. @@ -950,8 +991,10 @@ def sample_list_connectors(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.vpcaccess_v1.services.vpc_access_service.pagers.ListConnectorsPager: @@ -1023,7 +1066,7 @@ def delete_connector( name: Optional[str] = None, retry: OptionalRetry = gapic_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 Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist. @@ -1072,8 +1115,10 @@ def sample_delete_connector(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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 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. @@ -1172,8 +1217,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. @@ -1214,7 +1261,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. @@ -1225,8 +1272,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. @@ -1267,7 +1316,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. @@ -1278,8 +1327,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-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/pagers.py b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/pagers.py index 1965d08054e1..75ce612acee8 100644 --- a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/pagers.py +++ b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_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 = vpc_access.ListConnectorsRequest(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 = vpc_access.ListConnectorsRequest(request) diff --git a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/transports/grpc.py b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/transports/grpc.py index 018777049b61..c2271f45eafa 100644 --- a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/transports/grpc.py +++ b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_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,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.vpcaccess_v1.types import vpc_access from .base import DEFAULT_CLIENT_INFO, VpcAccessServiceTransport +try: + from google.api_core import client_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.vpcaccess.v1.VpcAccessService", + "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.vpcaccess.v1.VpcAccessService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VpcAccessServiceGrpcTransport(VpcAccessServiceTransport): """gRPC backend transport for VpcAccessService. @@ -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 create_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_connector" not in self._stubs: - self._stubs["create_connector"] = self.grpc_channel.unary_unary( + self._stubs["create_connector"] = self._logged_channel.unary_unary( "/google.cloud.vpcaccess.v1.VpcAccessService/CreateConnector", request_serializer=vpc_access.CreateConnectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -300,7 +388,7 @@ def get_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_connector" not in self._stubs: - self._stubs["get_connector"] = self.grpc_channel.unary_unary( + self._stubs["get_connector"] = self._logged_channel.unary_unary( "/google.cloud.vpcaccess.v1.VpcAccessService/GetConnector", request_serializer=vpc_access.GetConnectorRequest.serialize, response_deserializer=vpc_access.Connector.deserialize, @@ -328,7 +416,7 @@ def list_connectors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_connectors" not in self._stubs: - self._stubs["list_connectors"] = self.grpc_channel.unary_unary( + self._stubs["list_connectors"] = self._logged_channel.unary_unary( "/google.cloud.vpcaccess.v1.VpcAccessService/ListConnectors", request_serializer=vpc_access.ListConnectorsRequest.serialize, response_deserializer=vpc_access.ListConnectorsResponse.deserialize, @@ -355,7 +443,7 @@ def delete_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_connector" not in self._stubs: - self._stubs["delete_connector"] = self.grpc_channel.unary_unary( + self._stubs["delete_connector"] = self._logged_channel.unary_unary( "/google.cloud.vpcaccess.v1.VpcAccessService/DeleteConnector", request_serializer=vpc_access.DeleteConnectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -363,7 +451,7 @@ def delete_connector( return self._stubs["delete_connector"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -375,7 +463,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, @@ -394,7 +482,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, @@ -413,7 +501,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, diff --git a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/transports/grpc_asyncio.py b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/transports/grpc_asyncio.py index 43029bf41113..5bb36f89d9a1 100644 --- a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_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,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.vpcaccess_v1.types import vpc_access from .base import DEFAULT_CLIENT_INFO, VpcAccessServiceTransport from .grpc import VpcAccessServiceGrpcTransport +try: + from google.api_core import client_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.vpcaccess.v1.VpcAccessService", + "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.vpcaccess.v1.VpcAccessService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VpcAccessServiceGrpcAsyncIOTransport(VpcAccessServiceTransport): """gRPC AsyncIO backend transport for VpcAccessService. @@ -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 create_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_connector" not in self._stubs: - self._stubs["create_connector"] = self.grpc_channel.unary_unary( + self._stubs["create_connector"] = self._logged_channel.unary_unary( "/google.cloud.vpcaccess.v1.VpcAccessService/CreateConnector", request_serializer=vpc_access.CreateConnectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -312,7 +397,7 @@ def get_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_connector" not in self._stubs: - self._stubs["get_connector"] = self.grpc_channel.unary_unary( + self._stubs["get_connector"] = self._logged_channel.unary_unary( "/google.cloud.vpcaccess.v1.VpcAccessService/GetConnector", request_serializer=vpc_access.GetConnectorRequest.serialize, response_deserializer=vpc_access.Connector.deserialize, @@ -340,7 +425,7 @@ def list_connectors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_connectors" not in self._stubs: - self._stubs["list_connectors"] = self.grpc_channel.unary_unary( + self._stubs["list_connectors"] = self._logged_channel.unary_unary( "/google.cloud.vpcaccess.v1.VpcAccessService/ListConnectors", request_serializer=vpc_access.ListConnectorsRequest.serialize, response_deserializer=vpc_access.ListConnectorsResponse.deserialize, @@ -369,7 +454,7 @@ def delete_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_connector" not in self._stubs: - self._stubs["delete_connector"] = self.grpc_channel.unary_unary( + self._stubs["delete_connector"] = self._logged_channel.unary_unary( "/google.cloud.vpcaccess.v1.VpcAccessService/DeleteConnector", request_serializer=vpc_access.DeleteConnectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -422,7 +507,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: @@ -438,7 +523,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 +542,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 +561,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, diff --git a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/transports/rest.py b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/transports/rest.py index 3bd78bd610a7..a1c7d5539ab1 100644 --- a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/transports/rest.py +++ b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_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 @@ -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, @@ -103,8 +111,10 @@ def post_list_connectors(self, response): def pre_create_connector( self, request: vpc_access.CreateConnectorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vpc_access.CreateConnectorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vpc_access.CreateConnectorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_connector Override in a subclass to manipulate the request or metadata @@ -126,8 +136,10 @@ def post_create_connector( def pre_delete_connector( self, request: vpc_access.DeleteConnectorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vpc_access.DeleteConnectorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vpc_access.DeleteConnectorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_connector Override in a subclass to manipulate the request or metadata @@ -149,8 +161,8 @@ def post_delete_connector( def pre_get_connector( self, request: vpc_access.GetConnectorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vpc_access.GetConnectorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vpc_access.GetConnectorRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_connector Override in a subclass to manipulate the request or metadata @@ -172,8 +184,10 @@ def post_get_connector( def pre_list_connectors( self, request: vpc_access.ListConnectorsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vpc_access.ListConnectorsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vpc_access.ListConnectorsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_connectors Override in a subclass to manipulate the request or metadata @@ -195,8 +209,10 @@ def post_list_connectors( 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 @@ -218,8 +234,10 @@ def post_list_locations( 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 @@ -241,8 +259,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 @@ -427,7 +447,7 @@ 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 connector method over HTTP. @@ -438,8 +458,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -452,6 +474,7 @@ def __call__( http_options = ( _BaseVpcAccessServiceRestTransport._BaseCreateConnector._get_http_options() ) + request, metadata = self._interceptor.pre_create_connector( request, metadata ) @@ -468,6 +491,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vpcaccess_v1.VpcAccessServiceClient.CreateConnector", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "CreateConnector", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpcAccessServiceRestTransport._CreateConnector._get_response( self._host, @@ -487,7 +537,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_connector(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vpcaccess_v1.VpcAccessServiceClient.create_connector", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "CreateConnector", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteConnector( @@ -525,7 +597,7 @@ 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 connector method over HTTP. @@ -536,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: ~.operations_pb2.Operation: @@ -550,6 +624,7 @@ def __call__( http_options = ( _BaseVpcAccessServiceRestTransport._BaseDeleteConnector._get_http_options() ) + request, metadata = self._interceptor.pre_delete_connector( request, metadata ) @@ -562,6 +637,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vpcaccess_v1.VpcAccessServiceClient.DeleteConnector", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "DeleteConnector", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpcAccessServiceRestTransport._DeleteConnector._get_response( self._host, @@ -580,7 +682,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_connector(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vpcaccess_v1.VpcAccessServiceClient.delete_connector", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "DeleteConnector", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetConnector( @@ -617,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]]] = (), ) -> vpc_access.Connector: r"""Call the get connector method over HTTP. @@ -628,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: ~.vpc_access.Connector: @@ -641,6 +767,7 @@ def __call__( http_options = ( _BaseVpcAccessServiceRestTransport._BaseGetConnector._get_http_options() ) + request, metadata = self._interceptor.pre_get_connector(request, metadata) transcoded_request = _BaseVpcAccessServiceRestTransport._BaseGetConnector._get_transcoded_request( http_options, request @@ -651,6 +778,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vpcaccess_v1.VpcAccessServiceClient.GetConnector", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "GetConnector", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpcAccessServiceRestTransport._GetConnector._get_response( self._host, @@ -671,7 +825,29 @@ def __call__( pb_resp = vpc_access.Connector.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_connector(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vpc_access.Connector.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vpcaccess_v1.VpcAccessServiceClient.get_connector", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "GetConnector", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListConnectors( @@ -708,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]]] = (), ) -> vpc_access.ListConnectorsResponse: r"""Call the list connectors method over HTTP. @@ -719,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: ~.vpc_access.ListConnectorsResponse: @@ -732,6 +910,7 @@ def __call__( http_options = ( _BaseVpcAccessServiceRestTransport._BaseListConnectors._get_http_options() ) + request, metadata = self._interceptor.pre_list_connectors(request, metadata) transcoded_request = _BaseVpcAccessServiceRestTransport._BaseListConnectors._get_transcoded_request( http_options, request @@ -742,6 +921,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vpcaccess_v1.VpcAccessServiceClient.ListConnectors", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "ListConnectors", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpcAccessServiceRestTransport._ListConnectors._get_response( self._host, @@ -762,7 +968,31 @@ def __call__( pb_resp = vpc_access.ListConnectorsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_connectors(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vpc_access.ListConnectorsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vpcaccess_v1.VpcAccessServiceClient.list_connectors", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "ListConnectors", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -837,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]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -847,8 +1077,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -857,6 +1089,7 @@ def __call__( http_options = ( _BaseVpcAccessServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseVpcAccessServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -867,6 +1100,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vpcaccess_v1.VpcAccessServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpcAccessServiceRestTransport._ListLocations._get_response( self._host, @@ -886,6 +1146,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.vpcaccess_v1.VpcAccessServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -926,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -936,8 +1217,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -946,6 +1229,7 @@ def __call__( http_options = ( _BaseVpcAccessServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseVpcAccessServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -956,6 +1240,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vpcaccess_v1.VpcAccessServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpcAccessServiceRestTransport._GetOperation._get_response( self._host, @@ -975,6 +1286,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.vpcaccess_v1.VpcAccessServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1015,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.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1025,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.ListOperationsResponse: Response from ListOperations method. @@ -1035,6 +1369,7 @@ def __call__( http_options = ( _BaseVpcAccessServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseVpcAccessServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1045,6 +1380,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.vpcaccess_v1.VpcAccessServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpcAccessServiceRestTransport._ListOperations._get_response( self._host, @@ -1064,6 +1426,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.vpcaccess_v1.VpcAccessServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-vpc-access/samples/generated_samples/snippet_metadata_google.cloud.vpcaccess.v1.json b/packages/google-cloud-vpc-access/samples/generated_samples/snippet_metadata_google.cloud.vpcaccess.v1.json index d00c14f226a2..97bc0f76d20d 100644 --- a/packages/google-cloud-vpc-access/samples/generated_samples/snippet_metadata_google.cloud.vpcaccess.v1.json +++ b/packages/google-cloud-vpc-access/samples/generated_samples/snippet_metadata_google.cloud.vpcaccess.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-vpc-access", - "version": "1.11.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", @@ -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.vpcaccess_v1.types.Connector", @@ -465,7 +465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vpcaccess_v1.types.Connector", @@ -546,7 +546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vpcaccess_v1.services.vpc_access_service.pagers.ListConnectorsAsyncPager", @@ -626,7 +626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vpcaccess_v1.services.vpc_access_service.pagers.ListConnectorsPager", diff --git a/packages/google-cloud-vpc-access/tests/unit/gapic/vpcaccess_v1/test_vpc_access_service.py b/packages/google-cloud-vpc-access/tests/unit/gapic/vpcaccess_v1/test_vpc_access_service.py index 5684d551915d..870232fe7dd8 100644 --- a/packages/google-cloud-vpc-access/tests/unit/gapic/vpcaccess_v1/test_vpc_access_service.py +++ b/packages/google-cloud-vpc-access/tests/unit/gapic/vpcaccess_v1/test_vpc_access_service.py @@ -2775,6 +2775,7 @@ def test_create_connector_rest_required_fields( response_value._content = json_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_connector(request) @@ -2835,6 +2836,7 @@ def test_create_connector_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_connector(**mock_args) @@ -2967,6 +2969,7 @@ def test_get_connector_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_connector(request) @@ -3014,6 +3017,7 @@ def test_get_connector_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_connector(**mock_args) @@ -3151,6 +3155,7 @@ def test_list_connectors_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_connectors(request) @@ -3204,6 +3209,7 @@ def test_list_connectors_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_connectors(**mock_args) @@ -3398,6 +3404,7 @@ def test_delete_connector_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_connector(request) @@ -3443,6 +3450,7 @@ def test_delete_connector_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_connector(**mock_args) @@ -3816,6 +3824,7 @@ def test_create_connector_rest_bad_request( response_value.status_code = 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_connector(request) @@ -3929,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.create_connector(request) # Establish that the response is the type that we expect. @@ -3970,6 +3980,7 @@ def test_create_connector_rest_interceptors(null_interceptor): req.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 @@ -4012,6 +4023,7 @@ def test_get_connector_rest_bad_request(request_type=vpc_access.GetConnectorRequ response_value.status_code = 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_connector(request) @@ -4056,6 +4068,7 @@ def test_get_connector_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_connector(request) # Establish that the response is the type that we expect. @@ -4103,6 +4116,7 @@ def test_get_connector_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vpc_access.Connector.to_json(vpc_access.Connector()) req.return_value.content = return_value @@ -4147,6 +4161,7 @@ def test_list_connectors_rest_bad_request( response_value.status_code = 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_connectors(request) @@ -4182,6 +4197,7 @@ def test_list_connectors_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_connectors(request) # Establish that the response is the type that we expect. @@ -4222,6 +4238,7 @@ def test_list_connectors_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = vpc_access.ListConnectorsResponse.to_json( vpc_access.ListConnectorsResponse() ) @@ -4268,6 +4285,7 @@ def test_delete_connector_rest_bad_request( response_value.status_code = 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_connector(request) @@ -4298,6 +4316,7 @@ def test_delete_connector_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_connector(request) # Establish that the response is the type that we expect. @@ -4339,6 +4358,7 @@ def test_delete_connector_rest_interceptors(null_interceptor): req.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 @@ -4383,6 +4403,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) @@ -4413,6 +4434,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) @@ -4443,6 +4465,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) @@ -4473,6 +4496,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) @@ -4503,6 +4527,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) @@ -4533,6 +4558,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-webrisk/google/cloud/webrisk/gapic_version.py b/packages/google-cloud-webrisk/google/cloud/webrisk/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk/gapic_version.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk/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-webrisk/google/cloud/webrisk_v1/gapic_version.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1/gapic_version.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_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-webrisk/google/cloud/webrisk_v1/services/web_risk_service/async_client.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/async_client.py index 82c58142ff1c..a849cbdbc036 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/async_client.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_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, WebRiskServiceTransport from .transports.grpc_asyncio import WebRiskServiceGrpcAsyncIOTransport +try: + from google.api_core import client_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 WebRiskServiceAsyncClient: """Web Risk API defines an interface to detect malicious URLs on @@ -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.webrisk_v1.WebRiskServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "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.webrisk.v1.WebRiskService", + "credentialsType": None, + }, + ) + async def compute_threat_list_diff( self, request: Optional[Union[webrisk.ComputeThreatListDiffRequest, dict]] = None, @@ -267,7 +299,7 @@ async def compute_threat_list_diff( constraints: Optional[webrisk.ComputeThreatListDiffRequest.Constraints] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.ComputeThreatListDiffResponse: r"""Gets the most recent threat list diffs. These diffs should be applied to a local database of hashes to keep @@ -341,8 +373,10 @@ async def sample_compute_threat_list_diff(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.webrisk_v1.types.ComputeThreatListDiffResponse: @@ -400,7 +434,7 @@ async def search_uris( threat_types: Optional[MutableSequence[webrisk.ThreatType]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.SearchUrisResponse: r"""This method is used to check whether a URI is on a given threatList. Multiple threatLists may be searched @@ -458,8 +492,10 @@ async def sample_search_uris(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.webrisk_v1.types.SearchUrisResponse: @@ -515,7 +551,7 @@ async def search_hashes( threat_types: Optional[MutableSequence[webrisk.ThreatType]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.SearchHashesResponse: r"""Gets the full hashes that match the requested hash prefix. This is used after a hash prefix is looked up in @@ -577,8 +613,10 @@ async def sample_search_hashes(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.webrisk_v1.types.SearchHashesResponse: @@ -634,7 +672,7 @@ async def create_submission( submission: Optional[webrisk.Submission] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.Submission: r"""Creates a Submission of a URI suspected of containing phishing content to be reviewed. If the result verifies the existence of @@ -699,8 +737,10 @@ async def sample_create_submission(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.webrisk_v1.types.Submission: @@ -762,7 +802,7 @@ async def submit_uri( *, retry: OptionalRetry = gapic_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"""Submits a URI suspected of containing malicious content to be reviewed. Returns a google.longrunning.Operation which, once the @@ -818,8 +858,10 @@ async def sample_submit_uri(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -876,7 +918,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. @@ -887,8 +929,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. @@ -929,7 +973,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. @@ -940,8 +984,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. @@ -982,7 +1028,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. @@ -998,8 +1044,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 """ @@ -1036,7 +1084,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. @@ -1051,8 +1099,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 """ diff --git a/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/client.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/client.py index 890971100cc0..0314d235bfe5 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/client.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_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 @@ -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( @@ -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.webrisk_v1.WebRiskServiceClient`.", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "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.webrisk.v1.WebRiskService", + "credentialsType": None, + }, + ) + def compute_threat_list_diff( self, request: Optional[Union[webrisk.ComputeThreatListDiffRequest, dict]] = None, @@ -636,7 +673,7 @@ def compute_threat_list_diff( constraints: Optional[webrisk.ComputeThreatListDiffRequest.Constraints] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.ComputeThreatListDiffResponse: r"""Gets the most recent threat list diffs. These diffs should be applied to a local database of hashes to keep @@ -710,8 +747,10 @@ def sample_compute_threat_list_diff(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.webrisk_v1.types.ComputeThreatListDiffResponse: @@ -766,7 +805,7 @@ def search_uris( threat_types: Optional[MutableSequence[webrisk.ThreatType]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.SearchUrisResponse: r"""This method is used to check whether a URI is on a given threatList. Multiple threatLists may be searched @@ -824,8 +863,10 @@ def sample_search_uris(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.webrisk_v1.types.SearchUrisResponse: @@ -878,7 +919,7 @@ def search_hashes( threat_types: Optional[MutableSequence[webrisk.ThreatType]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.SearchHashesResponse: r"""Gets the full hashes that match the requested hash prefix. This is used after a hash prefix is looked up in @@ -940,8 +981,10 @@ def sample_search_hashes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.webrisk_v1.types.SearchHashesResponse: @@ -994,7 +1037,7 @@ def create_submission( submission: Optional[webrisk.Submission] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.Submission: r"""Creates a Submission of a URI suspected of containing phishing content to be reviewed. If the result verifies the existence of @@ -1059,8 +1102,10 @@ def sample_create_submission(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.webrisk_v1.types.Submission: @@ -1119,7 +1164,7 @@ def submit_uri( *, retry: OptionalRetry = gapic_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"""Submits a URI suspected of containing malicious content to be reviewed. Returns a google.longrunning.Operation which, once the @@ -1175,8 +1220,10 @@ def sample_submit_uri(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1244,7 +1291,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. @@ -1255,8 +1302,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. @@ -1297,7 +1346,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. @@ -1308,8 +1357,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. @@ -1350,7 +1401,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. @@ -1366,8 +1417,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 """ @@ -1404,7 +1457,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. @@ -1419,8 +1472,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 """ diff --git a/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/transports/grpc.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/transports/grpc.py index f95d53de806f..849bb3b4d7bd 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/transports/grpc.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_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.webrisk_v1.types import webrisk from .base import DEFAULT_CLIENT_INFO, WebRiskServiceTransport +try: + from google.api_core import client_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.webrisk.v1.WebRiskService", + "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.webrisk.v1.WebRiskService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WebRiskServiceGrpcTransport(WebRiskServiceTransport): """gRPC backend transport for WebRiskService. @@ -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 @@ -279,7 +367,7 @@ def compute_threat_list_diff( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "compute_threat_list_diff" not in self._stubs: - self._stubs["compute_threat_list_diff"] = self.grpc_channel.unary_unary( + self._stubs["compute_threat_list_diff"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1.WebRiskService/ComputeThreatListDiff", request_serializer=webrisk.ComputeThreatListDiffRequest.serialize, response_deserializer=webrisk.ComputeThreatListDiffResponse.deserialize, @@ -310,7 +398,7 @@ def search_uris( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_uris" not in self._stubs: - self._stubs["search_uris"] = self.grpc_channel.unary_unary( + self._stubs["search_uris"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1.WebRiskService/SearchUris", request_serializer=webrisk.SearchUrisRequest.serialize, response_deserializer=webrisk.SearchUrisResponse.deserialize, @@ -341,7 +429,7 @@ def search_hashes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_hashes" not in self._stubs: - self._stubs["search_hashes"] = self.grpc_channel.unary_unary( + self._stubs["search_hashes"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1.WebRiskService/SearchHashes", request_serializer=webrisk.SearchHashesRequest.serialize, response_deserializer=webrisk.SearchHashesResponse.deserialize, @@ -375,7 +463,7 @@ def create_submission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_submission" not in self._stubs: - self._stubs["create_submission"] = self.grpc_channel.unary_unary( + self._stubs["create_submission"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1.WebRiskService/CreateSubmission", request_serializer=webrisk.CreateSubmissionRequest.serialize, response_deserializer=webrisk.Submission.deserialize, @@ -412,7 +500,7 @@ def submit_uri( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "submit_uri" not in self._stubs: - self._stubs["submit_uri"] = self.grpc_channel.unary_unary( + self._stubs["submit_uri"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1.WebRiskService/SubmitUri", request_serializer=webrisk.SubmitUriRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -420,7 +508,7 @@ def submit_uri( return self._stubs["submit_uri"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -432,7 +520,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, @@ -449,7 +537,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, @@ -466,7 +554,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, @@ -485,7 +573,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-webrisk/google/cloud/webrisk_v1/services/web_risk_service/transports/grpc_asyncio.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/transports/grpc_asyncio.py index c270d3ab1250..0317daf712e5 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_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.webrisk_v1.types import webrisk from .base import DEFAULT_CLIENT_INFO, WebRiskServiceTransport from .grpc import WebRiskServiceGrpcTransport +try: + from google.api_core import client_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.webrisk.v1.WebRiskService", + "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.webrisk.v1.WebRiskService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WebRiskServiceGrpcAsyncIOTransport(WebRiskServiceTransport): """gRPC AsyncIO backend transport for WebRiskService. @@ -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. @@ -290,7 +375,7 @@ def compute_threat_list_diff( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "compute_threat_list_diff" not in self._stubs: - self._stubs["compute_threat_list_diff"] = self.grpc_channel.unary_unary( + self._stubs["compute_threat_list_diff"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1.WebRiskService/ComputeThreatListDiff", request_serializer=webrisk.ComputeThreatListDiffRequest.serialize, response_deserializer=webrisk.ComputeThreatListDiffResponse.deserialize, @@ -321,7 +406,7 @@ def search_uris( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_uris" not in self._stubs: - self._stubs["search_uris"] = self.grpc_channel.unary_unary( + self._stubs["search_uris"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1.WebRiskService/SearchUris", request_serializer=webrisk.SearchUrisRequest.serialize, response_deserializer=webrisk.SearchUrisResponse.deserialize, @@ -354,7 +439,7 @@ def search_hashes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_hashes" not in self._stubs: - self._stubs["search_hashes"] = self.grpc_channel.unary_unary( + self._stubs["search_hashes"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1.WebRiskService/SearchHashes", request_serializer=webrisk.SearchHashesRequest.serialize, response_deserializer=webrisk.SearchHashesResponse.deserialize, @@ -388,7 +473,7 @@ def create_submission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_submission" not in self._stubs: - self._stubs["create_submission"] = self.grpc_channel.unary_unary( + self._stubs["create_submission"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1.WebRiskService/CreateSubmission", request_serializer=webrisk.CreateSubmissionRequest.serialize, response_deserializer=webrisk.Submission.deserialize, @@ -425,7 +510,7 @@ def submit_uri( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "submit_uri" not in self._stubs: - self._stubs["submit_uri"] = self.grpc_channel.unary_unary( + self._stubs["submit_uri"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1.WebRiskService/SubmitUri", request_serializer=webrisk.SubmitUriRequest.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 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, @@ -551,7 +636,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, @@ -568,7 +653,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, @@ -587,7 +672,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-webrisk/google/cloud/webrisk_v1/services/web_risk_service/transports/rest.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/transports/rest.py index 497a155871f2..10f0bc9a8962 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/transports/rest.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_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, @@ -110,8 +118,10 @@ def post_submit_uri(self, response): def pre_compute_threat_list_diff( self, request: webrisk.ComputeThreatListDiffRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[webrisk.ComputeThreatListDiffRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + webrisk.ComputeThreatListDiffRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for compute_threat_list_diff Override in a subclass to manipulate the request or metadata @@ -133,8 +143,10 @@ def post_compute_threat_list_diff( def pre_create_submission( self, request: webrisk.CreateSubmissionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[webrisk.CreateSubmissionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + webrisk.CreateSubmissionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_submission Override in a subclass to manipulate the request or metadata @@ -154,8 +166,10 @@ def post_create_submission( return response def pre_search_hashes( - self, request: webrisk.SearchHashesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[webrisk.SearchHashesRequest, Sequence[Tuple[str, str]]]: + self, + request: webrisk.SearchHashesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[webrisk.SearchHashesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search_hashes Override in a subclass to manipulate the request or metadata @@ -175,8 +189,10 @@ def post_search_hashes( return response def pre_search_uris( - self, request: webrisk.SearchUrisRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[webrisk.SearchUrisRequest, Sequence[Tuple[str, str]]]: + self, + request: webrisk.SearchUrisRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[webrisk.SearchUrisRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search_uris Override in a subclass to manipulate the request or metadata @@ -196,8 +212,10 @@ def post_search_uris( return response def pre_submit_uri( - self, request: webrisk.SubmitUriRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[webrisk.SubmitUriRequest, Sequence[Tuple[str, str]]]: + self, + request: webrisk.SubmitUriRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[webrisk.SubmitUriRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for submit_uri Override in a subclass to manipulate the request or metadata @@ -219,8 +237,10 @@ def post_submit_uri( 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 @@ -240,8 +260,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 @@ -261,8 +283,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 @@ -284,8 +308,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 @@ -481,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]]] = (), ) -> webrisk.ComputeThreatListDiffResponse: r"""Call the compute threat list diff method over HTTP. @@ -491,8 +517,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.webrisk.ComputeThreatListDiffResponse: @@ -502,6 +530,7 @@ def __call__( http_options = ( _BaseWebRiskServiceRestTransport._BaseComputeThreatListDiff._get_http_options() ) + request, metadata = self._interceptor.pre_compute_threat_list_diff( request, metadata ) @@ -514,6 +543,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.webrisk_v1.WebRiskServiceClient.ComputeThreatListDiff", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "ComputeThreatListDiff", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebRiskServiceRestTransport._ComputeThreatListDiff._get_response( self._host, @@ -534,7 +590,31 @@ def __call__( pb_resp = webrisk.ComputeThreatListDiffResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_compute_threat_list_diff(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = webrisk.ComputeThreatListDiffResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.webrisk_v1.WebRiskServiceClient.compute_threat_list_diff", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "ComputeThreatListDiff", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSubmission( @@ -572,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]]] = (), ) -> webrisk.Submission: r"""Call the create submission method over HTTP. @@ -583,8 +663,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.webrisk.Submission: @@ -596,6 +678,7 @@ def __call__( http_options = ( _BaseWebRiskServiceRestTransport._BaseCreateSubmission._get_http_options() ) + request, metadata = self._interceptor.pre_create_submission( request, metadata ) @@ -612,6 +695,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.webrisk_v1.WebRiskServiceClient.CreateSubmission", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "CreateSubmission", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebRiskServiceRestTransport._CreateSubmission._get_response( self._host, @@ -633,7 +743,29 @@ def __call__( pb_resp = webrisk.Submission.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_submission(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = webrisk.Submission.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.webrisk_v1.WebRiskServiceClient.create_submission", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "CreateSubmission", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchHashes( @@ -670,7 +802,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.SearchHashesResponse: r"""Call the search hashes method over HTTP. @@ -681,8 +813,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.webrisk.SearchHashesResponse: @@ -692,6 +826,7 @@ def __call__( http_options = ( _BaseWebRiskServiceRestTransport._BaseSearchHashes._get_http_options() ) + request, metadata = self._interceptor.pre_search_hashes(request, metadata) transcoded_request = _BaseWebRiskServiceRestTransport._BaseSearchHashes._get_transcoded_request( http_options, request @@ -702,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.webrisk_v1.WebRiskServiceClient.SearchHashes", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "SearchHashes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebRiskServiceRestTransport._SearchHashes._get_response( self._host, @@ -722,7 +884,29 @@ def __call__( pb_resp = webrisk.SearchHashesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_hashes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = webrisk.SearchHashesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.webrisk_v1.WebRiskServiceClient.search_hashes", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "SearchHashes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchUris( @@ -759,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]]] = (), ) -> webrisk.SearchUrisResponse: r"""Call the search uris 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: ~.webrisk.SearchUrisResponse: @@ -781,6 +967,7 @@ def __call__( http_options = ( _BaseWebRiskServiceRestTransport._BaseSearchUris._get_http_options() ) + request, metadata = self._interceptor.pre_search_uris(request, metadata) transcoded_request = _BaseWebRiskServiceRestTransport._BaseSearchUris._get_transcoded_request( http_options, request @@ -793,6 +980,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.webrisk_v1.WebRiskServiceClient.SearchUris", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "SearchUris", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebRiskServiceRestTransport._SearchUris._get_response( self._host, @@ -813,7 +1027,29 @@ def __call__( pb_resp = webrisk.SearchUrisResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_uris(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = webrisk.SearchUrisResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.webrisk_v1.WebRiskServiceClient.search_uris", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "SearchUris", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SubmitUri( @@ -851,7 +1087,7 @@ 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 uri method over HTTP. @@ -862,8 +1098,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -876,6 +1114,7 @@ def __call__( http_options = ( _BaseWebRiskServiceRestTransport._BaseSubmitUri._get_http_options() ) + request, metadata = self._interceptor.pre_submit_uri(request, metadata) transcoded_request = ( _BaseWebRiskServiceRestTransport._BaseSubmitUri._get_transcoded_request( @@ -896,6 +1135,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.webrisk_v1.WebRiskServiceClient.SubmitUri", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "SubmitUri", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebRiskServiceRestTransport._SubmitUri._get_response( self._host, @@ -915,7 +1181,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_uri(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.webrisk_v1.WebRiskServiceClient.submit_uri", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "SubmitUri", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1009,13 +1297,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 = ( _BaseWebRiskServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1032,6 +1323,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.webrisk_v1.WebRiskServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebRiskServiceRestTransport._CancelOperation._get_response( self._host, @@ -1088,7 +1406,7 @@ 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. @@ -1098,13 +1416,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 = ( _BaseWebRiskServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1117,6 +1438,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.webrisk_v1.WebRiskServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebRiskServiceRestTransport._DeleteOperation._get_response( self._host, @@ -1172,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1182,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: operations_pb2.Operation: Response from GetOperation method. @@ -1192,6 +1542,7 @@ def __call__( http_options = ( _BaseWebRiskServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseWebRiskServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1202,6 +1553,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.webrisk_v1.WebRiskServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebRiskServiceRestTransport._GetOperation._get_response( self._host, @@ -1221,6 +1599,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.webrisk_v1.WebRiskServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1261,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1271,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1281,6 +1682,7 @@ def __call__( http_options = ( _BaseWebRiskServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseWebRiskServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1291,6 +1693,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.webrisk_v1.WebRiskServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebRiskServiceRestTransport._ListOperations._get_response( self._host, @@ -1310,6 +1739,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.webrisk_v1.WebRiskServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/gapic_version.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/gapic_version.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_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-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/async_client.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/async_client.py index e0e80324b79b..ff4071527ce1 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/async_client.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/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, @@ -50,6 +51,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, WebRiskServiceV1Beta1Transport from .transports.grpc_asyncio import WebRiskServiceV1Beta1GrpcAsyncIOTransport +try: + from google.api_core import client_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 WebRiskServiceV1Beta1AsyncClient: """Web Risk v1beta1 API defines an interface to detect malicious @@ -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.webrisk_v1beta1.WebRiskServiceV1Beta1AsyncClient`.", + extra={ + "serviceName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1", + "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.webrisk.v1beta1.WebRiskServiceV1Beta1", + "credentialsType": None, + }, + ) + async def compute_threat_list_diff( self, request: Optional[Union[webrisk.ComputeThreatListDiffRequest, dict]] = None, @@ -270,7 +302,7 @@ async def compute_threat_list_diff( constraints: Optional[webrisk.ComputeThreatListDiffRequest.Constraints] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.ComputeThreatListDiffResponse: r"""Gets the most recent threat list diffs. @@ -327,8 +359,10 @@ async def sample_compute_threat_list_diff(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.webrisk_v1beta1.types.ComputeThreatListDiffResponse: @@ -386,7 +420,7 @@ async def search_uris( threat_types: Optional[MutableSequence[webrisk.ThreatType]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.SearchUrisResponse: r"""This method is used to check whether a URI is on a given threatList. @@ -439,8 +473,10 @@ async def sample_search_uris(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.webrisk_v1beta1.types.SearchUrisResponse: @@ -496,7 +532,7 @@ async def search_hashes( threat_types: Optional[MutableSequence[webrisk.ThreatType]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.SearchHashesResponse: r"""Gets the full hashes that match the requested hash prefix. This is used after a hash prefix is looked up in @@ -554,8 +590,10 @@ async def sample_search_hashes(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.webrisk_v1beta1.types.SearchHashesResponse: diff --git a/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/client.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/client.py index 51df8d87adbe..a5bf56a5f4f3 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/client.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/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.cloud.webrisk_v1beta1.types import webrisk @@ -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.webrisk_v1beta1.WebRiskServiceV1Beta1Client`.", + extra={ + "serviceName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1", + "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.webrisk.v1beta1.WebRiskServiceV1Beta1", + "credentialsType": None, + }, + ) + def compute_threat_list_diff( self, request: Optional[Union[webrisk.ComputeThreatListDiffRequest, dict]] = None, @@ -640,7 +677,7 @@ def compute_threat_list_diff( constraints: Optional[webrisk.ComputeThreatListDiffRequest.Constraints] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.ComputeThreatListDiffResponse: r"""Gets the most recent threat list diffs. @@ -697,8 +734,10 @@ def sample_compute_threat_list_diff(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.webrisk_v1beta1.types.ComputeThreatListDiffResponse: @@ -753,7 +792,7 @@ def search_uris( threat_types: Optional[MutableSequence[webrisk.ThreatType]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.SearchUrisResponse: r"""This method is used to check whether a URI is on a given threatList. @@ -806,8 +845,10 @@ def sample_search_uris(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.webrisk_v1beta1.types.SearchUrisResponse: @@ -860,7 +901,7 @@ def search_hashes( threat_types: Optional[MutableSequence[webrisk.ThreatType]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.SearchHashesResponse: r"""Gets the full hashes that match the requested hash prefix. This is used after a hash prefix is looked up in @@ -918,8 +959,10 @@ def sample_search_hashes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.webrisk_v1beta1.types.SearchHashesResponse: diff --git a/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/transports/grpc.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/transports/grpc.py index d4dcfcf4d20e..dfb4ddf9f4f7 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/transports/grpc.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/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.cloud.webrisk_v1beta1.types import webrisk from .base import DEFAULT_CLIENT_INFO, WebRiskServiceV1Beta1Transport +try: + from google.api_core import client_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.webrisk.v1beta1.WebRiskServiceV1Beta1", + "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.webrisk.v1beta1.WebRiskServiceV1Beta1", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WebRiskServiceV1Beta1GrpcTransport(WebRiskServiceV1Beta1Transport): """gRPC backend transport for WebRiskServiceV1Beta1. @@ -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 compute_threat_list_diff( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "compute_threat_list_diff" not in self._stubs: - self._stubs["compute_threat_list_diff"] = self.grpc_channel.unary_unary( + self._stubs["compute_threat_list_diff"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1/ComputeThreatListDiff", request_serializer=webrisk.ComputeThreatListDiffRequest.serialize, response_deserializer=webrisk.ComputeThreatListDiffResponse.deserialize, @@ -283,7 +369,7 @@ def search_uris( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_uris" not in self._stubs: - self._stubs["search_uris"] = self.grpc_channel.unary_unary( + self._stubs["search_uris"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1/SearchUris", request_serializer=webrisk.SearchUrisRequest.serialize, response_deserializer=webrisk.SearchUrisResponse.deserialize, @@ -314,7 +400,7 @@ def search_hashes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_hashes" not in self._stubs: - self._stubs["search_hashes"] = self.grpc_channel.unary_unary( + self._stubs["search_hashes"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1/SearchHashes", request_serializer=webrisk.SearchHashesRequest.serialize, response_deserializer=webrisk.SearchHashesResponse.deserialize, @@ -322,7 +408,7 @@ def search_hashes( return self._stubs["search_hashes"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/transports/grpc_asyncio.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/transports/grpc_asyncio.py index 4173775dace8..050d535afe94 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/transports/grpc_asyncio.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/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.cloud.webrisk_v1beta1.types import webrisk from .base import DEFAULT_CLIENT_INFO, WebRiskServiceV1Beta1Transport from .grpc import WebRiskServiceV1Beta1GrpcTransport +try: + from google.api_core import client_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.webrisk.v1beta1.WebRiskServiceV1Beta1", + "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.webrisk.v1beta1.WebRiskServiceV1Beta1", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WebRiskServiceV1Beta1GrpcAsyncIOTransport(WebRiskServiceV1Beta1Transport): """gRPC AsyncIO backend transport for WebRiskServiceV1Beta1. @@ -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 compute_threat_list_diff( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "compute_threat_list_diff" not in self._stubs: - self._stubs["compute_threat_list_diff"] = self.grpc_channel.unary_unary( + self._stubs["compute_threat_list_diff"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1/ComputeThreatListDiff", request_serializer=webrisk.ComputeThreatListDiffRequest.serialize, response_deserializer=webrisk.ComputeThreatListDiffResponse.deserialize, @@ -292,7 +377,7 @@ def search_uris( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_uris" not in self._stubs: - self._stubs["search_uris"] = self.grpc_channel.unary_unary( + self._stubs["search_uris"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1/SearchUris", request_serializer=webrisk.SearchUrisRequest.serialize, response_deserializer=webrisk.SearchUrisResponse.deserialize, @@ -325,7 +410,7 @@ def search_hashes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_hashes" not in self._stubs: - self._stubs["search_hashes"] = self.grpc_channel.unary_unary( + self._stubs["search_hashes"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1/SearchHashes", request_serializer=webrisk.SearchHashesRequest.serialize, response_deserializer=webrisk.SearchHashesResponse.deserialize, @@ -388,7 +473,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-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/transports/rest.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/transports/rest.py index bd060484d592..d55b80c24fb1 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/transports/rest.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/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_search_uris(self, response): def pre_compute_threat_list_diff( self, request: webrisk.ComputeThreatListDiffRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[webrisk.ComputeThreatListDiffRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + webrisk.ComputeThreatListDiffRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for compute_threat_list_diff Override in a subclass to manipulate the request or metadata @@ -114,8 +124,10 @@ def post_compute_threat_list_diff( return response def pre_search_hashes( - self, request: webrisk.SearchHashesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[webrisk.SearchHashesRequest, Sequence[Tuple[str, str]]]: + self, + request: webrisk.SearchHashesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[webrisk.SearchHashesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search_hashes Override in a subclass to manipulate the request or metadata @@ -135,8 +147,10 @@ def post_search_hashes( return response def pre_search_uris( - self, request: webrisk.SearchUrisRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[webrisk.SearchUrisRequest, Sequence[Tuple[str, str]]]: + self, + request: webrisk.SearchUrisRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[webrisk.SearchUrisRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search_uris Override in a subclass to manipulate the request or metadata @@ -278,7 +292,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.ComputeThreatListDiffResponse: r"""Call the compute threat list diff 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: ~.webrisk.ComputeThreatListDiffResponse: @@ -299,6 +315,7 @@ def __call__( http_options = ( _BaseWebRiskServiceV1Beta1RestTransport._BaseComputeThreatListDiff._get_http_options() ) + request, metadata = self._interceptor.pre_compute_threat_list_diff( request, metadata ) @@ -311,6 +328,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.webrisk_v1beta1.WebRiskServiceV1Beta1Client.ComputeThreatListDiff", + extra={ + "serviceName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1", + "rpcName": "ComputeThreatListDiff", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( WebRiskServiceV1Beta1RestTransport._ComputeThreatListDiff._get_response( @@ -333,7 +377,31 @@ def __call__( pb_resp = webrisk.ComputeThreatListDiffResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_compute_threat_list_diff(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = webrisk.ComputeThreatListDiffResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.webrisk_v1beta1.WebRiskServiceV1Beta1Client.compute_threat_list_diff", + extra={ + "serviceName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1", + "rpcName": "ComputeThreatListDiff", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchHashes( @@ -371,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]]] = (), ) -> webrisk.SearchHashesResponse: r"""Call the search hashes method over HTTP. @@ -382,8 +450,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.webrisk.SearchHashesResponse: @@ -393,6 +463,7 @@ def __call__( http_options = ( _BaseWebRiskServiceV1Beta1RestTransport._BaseSearchHashes._get_http_options() ) + request, metadata = self._interceptor.pre_search_hashes(request, metadata) transcoded_request = _BaseWebRiskServiceV1Beta1RestTransport._BaseSearchHashes._get_transcoded_request( http_options, request @@ -403,6 +474,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.webrisk_v1beta1.WebRiskServiceV1Beta1Client.SearchHashes", + extra={ + "serviceName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1", + "rpcName": "SearchHashes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebRiskServiceV1Beta1RestTransport._SearchHashes._get_response( self._host, @@ -423,7 +521,29 @@ def __call__( pb_resp = webrisk.SearchHashesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_hashes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = webrisk.SearchHashesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.webrisk_v1beta1.WebRiskServiceV1Beta1Client.search_hashes", + extra={ + "serviceName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1", + "rpcName": "SearchHashes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchUris( @@ -461,7 +581,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.SearchUrisResponse: r"""Call the search uris method over HTTP. @@ -472,8 +592,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.webrisk.SearchUrisResponse: @@ -483,6 +605,7 @@ def __call__( http_options = ( _BaseWebRiskServiceV1Beta1RestTransport._BaseSearchUris._get_http_options() ) + request, metadata = self._interceptor.pre_search_uris(request, metadata) transcoded_request = _BaseWebRiskServiceV1Beta1RestTransport._BaseSearchUris._get_transcoded_request( http_options, request @@ -493,6 +616,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.webrisk_v1beta1.WebRiskServiceV1Beta1Client.SearchUris", + extra={ + "serviceName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1", + "rpcName": "SearchUris", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebRiskServiceV1Beta1RestTransport._SearchUris._get_response( self._host, @@ -513,7 +663,29 @@ def __call__( pb_resp = webrisk.SearchUrisResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_uris(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = webrisk.SearchUrisResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.webrisk_v1beta1.WebRiskServiceV1Beta1Client.search_uris", + extra={ + "serviceName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1", + "rpcName": "SearchUris", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-webrisk/samples/generated_samples/snippet_metadata_google.cloud.webrisk.v1.json b/packages/google-cloud-webrisk/samples/generated_samples/snippet_metadata_google.cloud.webrisk.v1.json index 02fb21b7f7f9..654bd4d32e74 100644 --- a/packages/google-cloud-webrisk/samples/generated_samples/snippet_metadata_google.cloud.webrisk.v1.json +++ b/packages/google-cloud-webrisk/samples/generated_samples/snippet_metadata_google.cloud.webrisk.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-webrisk", - "version": "1.15.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.cloud.webrisk_v1.types.ComputeThreatListDiffResponse", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1.types.ComputeThreatListDiffResponse", @@ -228,7 +228,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1.types.Submission", @@ -312,7 +312,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1.types.Submission", @@ -397,7 +397,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1.types.SearchHashesResponse", @@ -481,7 +481,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1.types.SearchHashesResponse", @@ -566,7 +566,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1.types.SearchUrisResponse", @@ -650,7 +650,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1.types.SearchUrisResponse", @@ -727,7 +727,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", diff --git a/packages/google-cloud-webrisk/samples/generated_samples/snippet_metadata_google.cloud.webrisk.v1beta1.json b/packages/google-cloud-webrisk/samples/generated_samples/snippet_metadata_google.cloud.webrisk.v1beta1.json index e93ea959de17..e281efca18fe 100644 --- a/packages/google-cloud-webrisk/samples/generated_samples/snippet_metadata_google.cloud.webrisk.v1beta1.json +++ b/packages/google-cloud-webrisk/samples/generated_samples/snippet_metadata_google.cloud.webrisk.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-webrisk", - "version": "1.15.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.cloud.webrisk_v1beta1.types.ComputeThreatListDiffResponse", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1beta1.types.ComputeThreatListDiffResponse", @@ -228,7 +228,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1beta1.types.SearchHashesResponse", @@ -312,7 +312,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1beta1.types.SearchHashesResponse", @@ -397,7 +397,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1beta1.types.SearchUrisResponse", @@ -481,7 +481,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1beta1.types.SearchUrisResponse", diff --git a/packages/google-cloud-webrisk/tests/unit/gapic/webrisk_v1/test_web_risk_service.py b/packages/google-cloud-webrisk/tests/unit/gapic/webrisk_v1/test_web_risk_service.py index 19208898061c..e9bbbf3f9506 100644 --- a/packages/google-cloud-webrisk/tests/unit/gapic/webrisk_v1/test_web_risk_service.py +++ b/packages/google-cloud-webrisk/tests/unit/gapic/webrisk_v1/test_web_risk_service.py @@ -2619,6 +2619,7 @@ def test_compute_threat_list_diff_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.compute_threat_list_diff(request) @@ -2682,6 +2683,7 @@ def test_compute_threat_list_diff_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.compute_threat_list_diff(**mock_args) @@ -2823,6 +2825,7 @@ def test_search_uris_rest_required_fields(request_type=webrisk.SearchUrisRequest response_value._content = json_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_uris(request) @@ -2888,6 +2891,7 @@ def test_search_uris_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_uris(**mock_args) @@ -3018,6 +3022,7 @@ def test_search_hashes_rest_required_fields(request_type=webrisk.SearchHashesReq response_value._content = json_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_hashes(request) @@ -3072,6 +3077,7 @@ def test_search_hashes_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_hashes(**mock_args) @@ -3205,6 +3211,7 @@ def test_create_submission_rest_required_fields( response_value._content = json_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_submission(request) @@ -3259,6 +3266,7 @@ def test_create_submission_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_submission(**mock_args) @@ -3389,6 +3397,7 @@ def test_submit_uri_rest_required_fields(request_type=webrisk.SubmitUriRequest): response_value._content = json_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_uri(request) @@ -3806,6 +3815,7 @@ def test_compute_threat_list_diff_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.compute_threat_list_diff(request) @@ -3842,6 +3852,7 @@ def test_compute_threat_list_diff_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.compute_threat_list_diff(request) # Establish that the response is the type that we expect. @@ -3886,6 +3897,7 @@ def test_compute_threat_list_diff_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = webrisk.ComputeThreatListDiffResponse.to_json( webrisk.ComputeThreatListDiffResponse() ) @@ -3930,6 +3942,7 @@ def test_search_uris_rest_bad_request(request_type=webrisk.SearchUrisRequest): response_value.status_code = 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_uris(request) @@ -3963,6 +3976,7 @@ def test_search_uris_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_uris(request) # Establish that the response is the type that we expect. @@ -4000,6 +4014,7 @@ def test_search_uris_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = webrisk.SearchUrisResponse.to_json(webrisk.SearchUrisResponse()) req.return_value.content = return_value @@ -4042,6 +4057,7 @@ def test_search_hashes_rest_bad_request(request_type=webrisk.SearchHashesRequest response_value.status_code = 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_hashes(request) @@ -4075,6 +4091,7 @@ def test_search_hashes_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_hashes(request) # Establish that the response is the type that we expect. @@ -4112,6 +4129,7 @@ def test_search_hashes_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = webrisk.SearchHashesResponse.to_json( webrisk.SearchHashesResponse() ) @@ -4158,6 +4176,7 @@ def test_create_submission_rest_bad_request( response_value.status_code = 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_submission(request) @@ -4262,6 +4281,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_submission(request) # Establish that the response is the type that we expect. @@ -4303,6 +4323,7 @@ def test_create_submission_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = webrisk.Submission.to_json(webrisk.Submission()) req.return_value.content = return_value @@ -4345,6 +4366,7 @@ def test_submit_uri_rest_bad_request(request_type=webrisk.SubmitUriRequest): response_value.status_code = 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_uri(request) @@ -4375,6 +4397,7 @@ def test_submit_uri_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_uri(request) # Establish that the response is the type that we expect. @@ -4414,6 +4437,7 @@ def test_submit_uri_rest_interceptors(null_interceptor): req.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 @@ -4460,6 +4484,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) @@ -4490,6 +4515,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) @@ -4520,6 +4546,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) @@ -4550,6 +4577,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) @@ -4580,6 +4608,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) @@ -4610,6 +4639,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) @@ -4638,6 +4668,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) @@ -4668,6 +4699,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-webrisk/tests/unit/gapic/webrisk_v1beta1/test_web_risk_service_v1_beta1.py b/packages/google-cloud-webrisk/tests/unit/gapic/webrisk_v1beta1/test_web_risk_service_v1_beta1.py index 7f12fa6d2b5c..a5e283f4ec0b 100644 --- a/packages/google-cloud-webrisk/tests/unit/gapic/webrisk_v1beta1/test_web_risk_service_v1_beta1.py +++ b/packages/google-cloud-webrisk/tests/unit/gapic/webrisk_v1beta1/test_web_risk_service_v1_beta1.py @@ -2077,6 +2077,7 @@ def test_compute_threat_list_diff_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.compute_threat_list_diff(request) @@ -2140,6 +2141,7 @@ def test_compute_threat_list_diff_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.compute_threat_list_diff(**mock_args) @@ -2281,6 +2283,7 @@ def test_search_uris_rest_required_fields(request_type=webrisk.SearchUrisRequest response_value._content = json_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_uris(request) @@ -2346,6 +2349,7 @@ def test_search_uris_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_uris(**mock_args) @@ -2476,6 +2480,7 @@ def test_search_hashes_rest_required_fields(request_type=webrisk.SearchHashesReq response_value._content = json_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_hashes(request) @@ -2530,6 +2535,7 @@ def test_search_hashes_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_hashes(**mock_args) @@ -2851,6 +2857,7 @@ def test_compute_threat_list_diff_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.compute_threat_list_diff(request) @@ -2887,6 +2894,7 @@ def test_compute_threat_list_diff_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.compute_threat_list_diff(request) # Establish that the response is the type that we expect. @@ -2931,6 +2939,7 @@ def test_compute_threat_list_diff_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = webrisk.ComputeThreatListDiffResponse.to_json( webrisk.ComputeThreatListDiffResponse() ) @@ -2975,6 +2984,7 @@ def test_search_uris_rest_bad_request(request_type=webrisk.SearchUrisRequest): response_value.status_code = 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_uris(request) @@ -3008,6 +3018,7 @@ def test_search_uris_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_uris(request) # Establish that the response is the type that we expect. @@ -3045,6 +3056,7 @@ def test_search_uris_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = webrisk.SearchUrisResponse.to_json(webrisk.SearchUrisResponse()) req.return_value.content = return_value @@ -3087,6 +3099,7 @@ def test_search_hashes_rest_bad_request(request_type=webrisk.SearchHashesRequest response_value.status_code = 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_hashes(request) @@ -3120,6 +3133,7 @@ def test_search_hashes_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_hashes(request) # Establish that the response is the type that we expect. @@ -3157,6 +3171,7 @@ def test_search_hashes_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = webrisk.SearchHashesResponse.to_json( webrisk.SearchHashesResponse() ) diff --git a/packages/google-cloud-webrisk/webrisk-v1beta1-py.tar.gz b/packages/google-cloud-webrisk/webrisk-v1beta1-py.tar.gz new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner/gapic_version.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner/gapic_version.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner/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-websecurityscanner/google/cloud/websecurityscanner_v1/gapic_version.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/gapic_version.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_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-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/async_client.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/async_client.py index c65fa657162a..16693fb4fa2a 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/async_client.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/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, WebSecurityScannerTransport from .transports.grpc_asyncio import WebSecurityScannerGrpcAsyncIOTransport +try: + from google.api_core import client_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 WebSecurityScannerAsyncClient: """Web Security Scanner Service identifies security @@ -274,6 +284,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.websecurityscanner_v1.WebSecurityScannerAsyncClient`.", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "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.websecurityscanner.v1.WebSecurityScanner", + "credentialsType": None, + }, + ) + async def create_scan_config( self, request: Optional[ @@ -282,7 +314,7 @@ async def create_scan_config( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Creates a new ScanConfig. @@ -317,8 +349,10 @@ async def sample_create_scan_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.cloud.websecurityscanner_v1.types.ScanConfig: @@ -366,7 +400,7 @@ async def delete_scan_config( *, retry: OptionalRetry = 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 an existing ScanConfig and its child resources. @@ -399,8 +433,10 @@ async def sample_delete_scan_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`. """ # Create or coerce a protobuf request object. # - Use the request object if provided (there's no risk of modifying the input as @@ -439,7 +475,7 @@ async def get_scan_config( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Gets a ScanConfig. @@ -474,8 +510,10 @@ async def sample_get_scan_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.cloud.websecurityscanner_v1.types.ScanConfig: @@ -523,7 +561,7 @@ async def list_scan_configs( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListScanConfigsAsyncPager: r"""Lists ScanConfigs under a given project. @@ -559,8 +597,10 @@ async def sample_list_scan_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.websecurityscanner_v1.services.web_security_scanner.pagers.ListScanConfigsAsyncPager: @@ -621,7 +661,7 @@ async def update_scan_config( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Updates a ScanConfig. This method support partial update of a ScanConfig. @@ -657,8 +697,10 @@ async def sample_update_scan_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.cloud.websecurityscanner_v1.types.ScanConfig: @@ -706,7 +748,7 @@ async def start_scan_run( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Start a ScanRun according to the given ScanConfig. @@ -741,8 +783,10 @@ async def sample_start_scan_run(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1.types.ScanRun: @@ -789,7 +833,7 @@ async def get_scan_run( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Gets a ScanRun. @@ -824,8 +868,10 @@ async def sample_get_scan_run(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1.types.ScanRun: @@ -872,7 +918,7 @@ async def list_scan_runs( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListScanRunsAsyncPager: r"""Lists ScanRuns under a given ScanConfig, in descending order of ScanRun stop time. @@ -909,8 +955,10 @@ async def sample_list_scan_runs(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListScanRunsAsyncPager: @@ -969,7 +1017,7 @@ async def stop_scan_run( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Stops a ScanRun. The stopped ScanRun is returned. @@ -1004,8 +1052,10 @@ async def sample_stop_scan_run(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1.types.ScanRun: @@ -1054,7 +1104,7 @@ async def list_crawled_urls( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCrawledUrlsAsyncPager: r"""List CrawledUrls under a given ScanRun. @@ -1090,8 +1140,10 @@ async def sample_list_crawled_urls(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListCrawledUrlsAsyncPager: @@ -1150,7 +1202,7 @@ async def get_finding( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Gets a Finding. @@ -1185,8 +1237,10 @@ async def sample_get_finding(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1.types.Finding: @@ -1233,7 +1287,7 @@ async def list_findings( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFindingsAsyncPager: r"""List Findings under a given ScanRun. @@ -1269,8 +1323,10 @@ async def sample_list_findings(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListFindingsAsyncPager: @@ -1331,7 +1387,7 @@ async def list_finding_type_stats( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListFindingTypeStatsResponse: r"""List all FindingTypeStats under a given ScanRun. @@ -1366,8 +1422,10 @@ async def sample_list_finding_type_stats(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1.types.ListFindingTypeStatsResponse: diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/client.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/client.py index 85058aa16736..650b71708577 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/client.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/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.cloud.websecurityscanner_v1.services.web_security_scanner import pagers @@ -600,6 +610,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( @@ -666,6 +680,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.websecurityscanner_v1.WebSecurityScannerClient`.", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "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.websecurityscanner.v1.WebSecurityScanner", + "credentialsType": None, + }, + ) + def create_scan_config( self, request: Optional[ @@ -674,7 +711,7 @@ def create_scan_config( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Creates a new ScanConfig. @@ -709,8 +746,10 @@ def sample_create_scan_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.websecurityscanner_v1.types.ScanConfig: @@ -756,7 +795,7 @@ def delete_scan_config( *, retry: OptionalRetry = 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 an existing ScanConfig and its child resources. @@ -789,8 +828,10 @@ def sample_delete_scan_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`. """ # Create or coerce a protobuf request object. # - Use the request object if provided (there's no risk of modifying the input as @@ -827,7 +868,7 @@ def get_scan_config( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Gets a ScanConfig. @@ -862,8 +903,10 @@ def sample_get_scan_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.websecurityscanner_v1.types.ScanConfig: @@ -909,7 +952,7 @@ def list_scan_configs( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListScanConfigsPager: r"""Lists ScanConfigs under a given project. @@ -945,8 +988,10 @@ def sample_list_scan_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.websecurityscanner_v1.services.web_security_scanner.pagers.ListScanConfigsPager: @@ -1005,7 +1050,7 @@ def update_scan_config( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Updates a ScanConfig. This method support partial update of a ScanConfig. @@ -1041,8 +1086,10 @@ def sample_update_scan_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.websecurityscanner_v1.types.ScanConfig: @@ -1088,7 +1135,7 @@ def start_scan_run( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Start a ScanRun according to the given ScanConfig. @@ -1123,8 +1170,10 @@ def sample_start_scan_run(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1.types.ScanRun: @@ -1169,7 +1218,7 @@ def get_scan_run( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Gets a ScanRun. @@ -1204,8 +1253,10 @@ def sample_get_scan_run(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1.types.ScanRun: @@ -1250,7 +1301,7 @@ def list_scan_runs( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListScanRunsPager: r"""Lists ScanRuns under a given ScanConfig, in descending order of ScanRun stop time. @@ -1287,8 +1338,10 @@ def sample_list_scan_runs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListScanRunsPager: @@ -1345,7 +1398,7 @@ def stop_scan_run( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Stops a ScanRun. The stopped ScanRun is returned. @@ -1380,8 +1433,10 @@ def sample_stop_scan_run(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1.types.ScanRun: @@ -1428,7 +1483,7 @@ def list_crawled_urls( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCrawledUrlsPager: r"""List CrawledUrls under a given ScanRun. @@ -1464,8 +1519,10 @@ def sample_list_crawled_urls(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListCrawledUrlsPager: @@ -1522,7 +1579,7 @@ def get_finding( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Gets a Finding. @@ -1557,8 +1614,10 @@ def sample_get_finding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1.types.Finding: @@ -1603,7 +1662,7 @@ def list_findings( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFindingsPager: r"""List Findings under a given ScanRun. @@ -1639,8 +1698,10 @@ def sample_list_findings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListFindingsPager: @@ -1699,7 +1760,7 @@ def list_finding_type_stats( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListFindingTypeStatsResponse: r"""List all FindingTypeStats under a given ScanRun. @@ -1734,8 +1795,10 @@ def sample_list_finding_type_stats(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1.types.ListFindingTypeStatsResponse: diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/pagers.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/pagers.py index 16634ce4da4f..0f8a83b9d71e 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/pagers.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/pagers.py @@ -73,7 +73,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -87,8 +87,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = web_security_scanner.ListScanConfigsRequest(request) @@ -147,7 +149,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. @@ -161,8 +163,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 = web_security_scanner.ListScanConfigsRequest(request) @@ -227,7 +231,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -241,8 +245,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = web_security_scanner.ListScanRunsRequest(request) @@ -301,7 +307,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. @@ -315,8 +321,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 = web_security_scanner.ListScanRunsRequest(request) @@ -379,7 +387,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -393,8 +401,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = web_security_scanner.ListCrawledUrlsRequest(request) @@ -453,7 +463,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. @@ -467,8 +477,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 = web_security_scanner.ListCrawledUrlsRequest(request) @@ -533,7 +545,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -547,8 +559,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = web_security_scanner.ListFindingsRequest(request) @@ -607,7 +621,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. @@ -621,8 +635,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 = web_security_scanner.ListFindingsRequest(request) diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/grpc.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/grpc.py index ddf38dbfcabf..44322b681ad9 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/grpc.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/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.cloud.websecurityscanner_v1.types import ( finding, @@ -32,6 +38,81 @@ from .base import DEFAULT_CLIENT_INFO, WebSecurityScannerTransport +try: + from google.api_core import client_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.websecurityscanner.v1.WebSecurityScanner", + "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.websecurityscanner.v1.WebSecurityScanner", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WebSecurityScannerGrpcTransport(WebSecurityScannerTransport): """gRPC backend transport for WebSecurityScanner. @@ -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 create_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_scan_config" not in self._stubs: - self._stubs["create_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["create_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/CreateScanConfig", request_serializer=web_security_scanner.CreateScanConfigRequest.serialize, response_deserializer=scan_config.ScanConfig.deserialize, @@ -291,7 +377,7 @@ def delete_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_scan_config" not in self._stubs: - self._stubs["delete_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/DeleteScanConfig", request_serializer=web_security_scanner.DeleteScanConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -317,7 +403,7 @@ def get_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_scan_config" not in self._stubs: - self._stubs["get_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["get_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/GetScanConfig", request_serializer=web_security_scanner.GetScanConfigRequest.serialize, response_deserializer=scan_config.ScanConfig.deserialize, @@ -346,7 +432,7 @@ def list_scan_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_scan_configs" not in self._stubs: - self._stubs["list_scan_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_scan_configs"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/ListScanConfigs", request_serializer=web_security_scanner.ListScanConfigsRequest.serialize, response_deserializer=web_security_scanner.ListScanConfigsResponse.deserialize, @@ -375,7 +461,7 @@ def update_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_scan_config" not in self._stubs: - self._stubs["update_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["update_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/UpdateScanConfig", request_serializer=web_security_scanner.UpdateScanConfigRequest.serialize, response_deserializer=scan_config.ScanConfig.deserialize, @@ -401,7 +487,7 @@ def start_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_scan_run" not in self._stubs: - self._stubs["start_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["start_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/StartScanRun", request_serializer=web_security_scanner.StartScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -427,7 +513,7 @@ def get_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_scan_run" not in self._stubs: - self._stubs["get_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["get_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/GetScanRun", request_serializer=web_security_scanner.GetScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -457,7 +543,7 @@ def list_scan_runs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_scan_runs" not in self._stubs: - self._stubs["list_scan_runs"] = self.grpc_channel.unary_unary( + self._stubs["list_scan_runs"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/ListScanRuns", request_serializer=web_security_scanner.ListScanRunsRequest.serialize, response_deserializer=web_security_scanner.ListScanRunsResponse.deserialize, @@ -483,7 +569,7 @@ def stop_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_scan_run" not in self._stubs: - self._stubs["stop_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["stop_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/StopScanRun", request_serializer=web_security_scanner.StopScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -512,7 +598,7 @@ def list_crawled_urls( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_crawled_urls" not in self._stubs: - self._stubs["list_crawled_urls"] = self.grpc_channel.unary_unary( + self._stubs["list_crawled_urls"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/ListCrawledUrls", request_serializer=web_security_scanner.ListCrawledUrlsRequest.serialize, response_deserializer=web_security_scanner.ListCrawledUrlsResponse.deserialize, @@ -538,7 +624,7 @@ def get_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_finding" not in self._stubs: - self._stubs["get_finding"] = self.grpc_channel.unary_unary( + self._stubs["get_finding"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/GetFinding", request_serializer=web_security_scanner.GetFindingRequest.serialize, response_deserializer=finding.Finding.deserialize, @@ -567,7 +653,7 @@ def list_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_findings" not in self._stubs: - self._stubs["list_findings"] = self.grpc_channel.unary_unary( + self._stubs["list_findings"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/ListFindings", request_serializer=web_security_scanner.ListFindingsRequest.serialize, response_deserializer=web_security_scanner.ListFindingsResponse.deserialize, @@ -596,7 +682,7 @@ def list_finding_type_stats( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_finding_type_stats" not in self._stubs: - self._stubs["list_finding_type_stats"] = self.grpc_channel.unary_unary( + self._stubs["list_finding_type_stats"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/ListFindingTypeStats", request_serializer=web_security_scanner.ListFindingTypeStatsRequest.serialize, response_deserializer=web_security_scanner.ListFindingTypeStatsResponse.deserialize, @@ -604,7 +690,7 @@ def list_finding_type_stats( return self._stubs["list_finding_type_stats"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/grpc_asyncio.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/grpc_asyncio.py index d7504dfdb30f..e647944b4179 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/grpc_asyncio.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/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.cloud.websecurityscanner_v1.types import ( finding, @@ -36,6 +42,82 @@ from .base import DEFAULT_CLIENT_INFO, WebSecurityScannerTransport from .grpc import WebSecurityScannerGrpcTransport +try: + from google.api_core import client_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.websecurityscanner.v1.WebSecurityScanner", + "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.websecurityscanner.v1.WebSecurityScanner", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WebSecurityScannerGrpcAsyncIOTransport(WebSecurityScannerTransport): """gRPC AsyncIO backend transport for WebSecurityScanner. @@ -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 @@ -273,7 +358,7 @@ def create_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_scan_config" not in self._stubs: - self._stubs["create_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["create_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/CreateScanConfig", request_serializer=web_security_scanner.CreateScanConfigRequest.serialize, response_deserializer=scan_config.ScanConfig.deserialize, @@ -302,7 +387,7 @@ def delete_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_scan_config" not in self._stubs: - self._stubs["delete_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/DeleteScanConfig", request_serializer=web_security_scanner.DeleteScanConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -330,7 +415,7 @@ def get_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_scan_config" not in self._stubs: - self._stubs["get_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["get_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/GetScanConfig", request_serializer=web_security_scanner.GetScanConfigRequest.serialize, response_deserializer=scan_config.ScanConfig.deserialize, @@ -359,7 +444,7 @@ def list_scan_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_scan_configs" not in self._stubs: - self._stubs["list_scan_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_scan_configs"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/ListScanConfigs", request_serializer=web_security_scanner.ListScanConfigsRequest.serialize, response_deserializer=web_security_scanner.ListScanConfigsResponse.deserialize, @@ -389,7 +474,7 @@ def update_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_scan_config" not in self._stubs: - self._stubs["update_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["update_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/UpdateScanConfig", request_serializer=web_security_scanner.UpdateScanConfigRequest.serialize, response_deserializer=scan_config.ScanConfig.deserialize, @@ -417,7 +502,7 @@ def start_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_scan_run" not in self._stubs: - self._stubs["start_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["start_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/StartScanRun", request_serializer=web_security_scanner.StartScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -445,7 +530,7 @@ def get_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_scan_run" not in self._stubs: - self._stubs["get_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["get_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/GetScanRun", request_serializer=web_security_scanner.GetScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -475,7 +560,7 @@ def list_scan_runs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_scan_runs" not in self._stubs: - self._stubs["list_scan_runs"] = self.grpc_channel.unary_unary( + self._stubs["list_scan_runs"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/ListScanRuns", request_serializer=web_security_scanner.ListScanRunsRequest.serialize, response_deserializer=web_security_scanner.ListScanRunsResponse.deserialize, @@ -503,7 +588,7 @@ def stop_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_scan_run" not in self._stubs: - self._stubs["stop_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["stop_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/StopScanRun", request_serializer=web_security_scanner.StopScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -532,7 +617,7 @@ def list_crawled_urls( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_crawled_urls" not in self._stubs: - self._stubs["list_crawled_urls"] = self.grpc_channel.unary_unary( + self._stubs["list_crawled_urls"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/ListCrawledUrls", request_serializer=web_security_scanner.ListCrawledUrlsRequest.serialize, response_deserializer=web_security_scanner.ListCrawledUrlsResponse.deserialize, @@ -558,7 +643,7 @@ def get_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_finding" not in self._stubs: - self._stubs["get_finding"] = self.grpc_channel.unary_unary( + self._stubs["get_finding"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/GetFinding", request_serializer=web_security_scanner.GetFindingRequest.serialize, response_deserializer=finding.Finding.deserialize, @@ -587,7 +672,7 @@ def list_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_findings" not in self._stubs: - self._stubs["list_findings"] = self.grpc_channel.unary_unary( + self._stubs["list_findings"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/ListFindings", request_serializer=web_security_scanner.ListFindingsRequest.serialize, response_deserializer=web_security_scanner.ListFindingsResponse.deserialize, @@ -616,7 +701,7 @@ def list_finding_type_stats( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_finding_type_stats" not in self._stubs: - self._stubs["list_finding_type_stats"] = self.grpc_channel.unary_unary( + self._stubs["list_finding_type_stats"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/ListFindingTypeStats", request_serializer=web_security_scanner.ListFindingTypeStatsRequest.serialize, response_deserializer=web_security_scanner.ListFindingTypeStatsResponse.deserialize, @@ -789,7 +874,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-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/rest.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/rest.py index e391218e0948..0468accd4a1c 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/rest.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/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, @@ -175,8 +183,11 @@ def post_update_scan_config(self, response): def pre_create_scan_config( self, request: web_security_scanner.CreateScanConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.CreateScanConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.CreateScanConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_scan_config Override in a subclass to manipulate the request or metadata @@ -198,8 +209,11 @@ def post_create_scan_config( def pre_delete_scan_config( self, request: web_security_scanner.DeleteScanConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.DeleteScanConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.DeleteScanConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_scan_config Override in a subclass to manipulate the request or metadata @@ -210,8 +224,10 @@ def pre_delete_scan_config( def pre_get_finding( self, request: web_security_scanner.GetFindingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.GetFindingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.GetFindingRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_finding Override in a subclass to manipulate the request or metadata @@ -231,8 +247,11 @@ def post_get_finding(self, response: finding.Finding) -> finding.Finding: def pre_get_scan_config( self, request: web_security_scanner.GetScanConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.GetScanConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.GetScanConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_scan_config Override in a subclass to manipulate the request or metadata @@ -254,8 +273,10 @@ def post_get_scan_config( def pre_get_scan_run( self, request: web_security_scanner.GetScanRunRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.GetScanRunRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.GetScanRunRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_scan_run Override in a subclass to manipulate the request or metadata @@ -275,8 +296,11 @@ def post_get_scan_run(self, response: scan_run.ScanRun) -> scan_run.ScanRun: def pre_list_crawled_urls( self, request: web_security_scanner.ListCrawledUrlsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.ListCrawledUrlsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.ListCrawledUrlsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_crawled_urls Override in a subclass to manipulate the request or metadata @@ -298,8 +322,11 @@ def post_list_crawled_urls( def pre_list_findings( self, request: web_security_scanner.ListFindingsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.ListFindingsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.ListFindingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_findings Override in a subclass to manipulate the request or metadata @@ -321,9 +348,10 @@ def post_list_findings( def pre_list_finding_type_stats( self, request: web_security_scanner.ListFindingTypeStatsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - web_security_scanner.ListFindingTypeStatsRequest, Sequence[Tuple[str, str]] + web_security_scanner.ListFindingTypeStatsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_finding_type_stats @@ -346,8 +374,11 @@ def post_list_finding_type_stats( def pre_list_scan_configs( self, request: web_security_scanner.ListScanConfigsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.ListScanConfigsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.ListScanConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_scan_configs Override in a subclass to manipulate the request or metadata @@ -369,8 +400,11 @@ def post_list_scan_configs( def pre_list_scan_runs( self, request: web_security_scanner.ListScanRunsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.ListScanRunsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.ListScanRunsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_scan_runs Override in a subclass to manipulate the request or metadata @@ -392,8 +426,11 @@ def post_list_scan_runs( def pre_start_scan_run( self, request: web_security_scanner.StartScanRunRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.StartScanRunRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.StartScanRunRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for start_scan_run Override in a subclass to manipulate the request or metadata @@ -413,8 +450,10 @@ def post_start_scan_run(self, response: scan_run.ScanRun) -> scan_run.ScanRun: def pre_stop_scan_run( self, request: web_security_scanner.StopScanRunRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.StopScanRunRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.StopScanRunRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for stop_scan_run Override in a subclass to manipulate the request or metadata @@ -434,8 +473,11 @@ def post_stop_scan_run(self, response: scan_run.ScanRun) -> scan_run.ScanRun: def pre_update_scan_config( self, request: web_security_scanner.UpdateScanConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.UpdateScanConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.UpdateScanConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_scan_config Override in a subclass to manipulate the request or metadata @@ -580,7 +622,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Call the create scan config method over HTTP. @@ -590,8 +632,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.scan_config.ScanConfig: @@ -603,6 +647,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseCreateScanConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_scan_config( request, metadata ) @@ -619,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.websecurityscanner_v1.WebSecurityScannerClient.CreateScanConfig", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "CreateScanConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._CreateScanConfig._get_response( self._host, @@ -640,7 +712,29 @@ def __call__( pb_resp = scan_config.ScanConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_scan_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_config.ScanConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1.WebSecurityScannerClient.create_scan_config", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "CreateScanConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteScanConfig( @@ -678,7 +772,7 @@ 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 scan config method over HTTP. @@ -688,13 +782,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 = ( _BaseWebSecurityScannerRestTransport._BaseDeleteScanConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_scan_config( request, metadata ) @@ -707,6 +804,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1.WebSecurityScannerClient.DeleteScanConfig", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "DeleteScanConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._DeleteScanConfig._get_response( self._host, @@ -756,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]]] = (), ) -> finding.Finding: r"""Call the get finding method over HTTP. @@ -766,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: ~.finding.Finding: @@ -780,6 +906,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseGetFinding._get_http_options() ) + request, metadata = self._interceptor.pre_get_finding(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseGetFinding._get_transcoded_request( http_options, request @@ -790,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 = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1.WebSecurityScannerClient.GetFinding", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "GetFinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._GetFinding._get_response( self._host, @@ -810,7 +964,29 @@ def __call__( pb_resp = finding.Finding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_finding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = finding.Finding.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1.WebSecurityScannerClient.get_finding", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "GetFinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetScanConfig( @@ -848,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]]] = (), ) -> scan_config.ScanConfig: r"""Call the get scan config method over HTTP. @@ -858,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: ~.scan_config.ScanConfig: @@ -871,6 +1049,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseGetScanConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_scan_config(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseGetScanConfig._get_transcoded_request( http_options, request @@ -881,6 +1060,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1.WebSecurityScannerClient.GetScanConfig", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "GetScanConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._GetScanConfig._get_response( self._host, @@ -901,7 +1107,29 @@ def __call__( pb_resp = scan_config.ScanConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_scan_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_config.ScanConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1.WebSecurityScannerClient.get_scan_config", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "GetScanConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetScanRun( @@ -938,7 +1166,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Call the get scan run method over HTTP. @@ -948,8 +1176,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.scan_run.ScanRun: @@ -962,6 +1192,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseGetScanRun._get_http_options() ) + request, metadata = self._interceptor.pre_get_scan_run(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseGetScanRun._get_transcoded_request( http_options, request @@ -972,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.websecurityscanner_v1.WebSecurityScannerClient.GetScanRun", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "GetScanRun", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._GetScanRun._get_response( self._host, @@ -992,7 +1250,29 @@ def __call__( pb_resp = scan_run.ScanRun.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_scan_run(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_run.ScanRun.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1.WebSecurityScannerClient.get_scan_run", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "GetScanRun", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCrawledUrls( @@ -1030,7 +1310,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListCrawledUrlsResponse: r"""Call the list crawled urls method over HTTP. @@ -1040,8 +1320,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.web_security_scanner.ListCrawledUrlsResponse: @@ -1051,6 +1333,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListCrawledUrls._get_http_options() ) + request, metadata = self._interceptor.pre_list_crawled_urls( request, metadata ) @@ -1063,6 +1346,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1.WebSecurityScannerClient.ListCrawledUrls", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "ListCrawledUrls", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._ListCrawledUrls._get_response( self._host, @@ -1083,7 +1393,31 @@ def __call__( pb_resp = web_security_scanner.ListCrawledUrlsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_crawled_urls(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListCrawledUrlsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1.WebSecurityScannerClient.list_crawled_urls", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "ListCrawledUrls", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListFindings( @@ -1121,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]]] = (), ) -> web_security_scanner.ListFindingsResponse: r"""Call the list findings method over HTTP. @@ -1131,8 +1465,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.web_security_scanner.ListFindingsResponse: @@ -1142,6 +1478,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListFindings._get_http_options() ) + request, metadata = self._interceptor.pre_list_findings(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseListFindings._get_transcoded_request( http_options, request @@ -1152,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.websecurityscanner_v1.WebSecurityScannerClient.ListFindings", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "ListFindings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._ListFindings._get_response( self._host, @@ -1172,7 +1536,31 @@ def __call__( pb_resp = web_security_scanner.ListFindingsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_findings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListFindingsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1.WebSecurityScannerClient.list_findings", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "ListFindings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListFindingTypeStats( @@ -1210,7 +1598,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListFindingTypeStatsResponse: r"""Call the list finding type stats method over HTTP. @@ -1220,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: ~.web_security_scanner.ListFindingTypeStatsResponse: @@ -1231,6 +1621,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListFindingTypeStats._get_http_options() ) + request, metadata = self._interceptor.pre_list_finding_type_stats( request, metadata ) @@ -1243,6 +1634,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1.WebSecurityScannerClient.ListFindingTypeStats", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "ListFindingTypeStats", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( WebSecurityScannerRestTransport._ListFindingTypeStats._get_response( @@ -1265,7 +1683,33 @@ def __call__( pb_resp = web_security_scanner.ListFindingTypeStatsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_finding_type_stats(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListFindingTypeStatsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1.WebSecurityScannerClient.list_finding_type_stats", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "ListFindingTypeStats", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListScanConfigs( @@ -1303,7 +1747,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListScanConfigsResponse: r"""Call the list scan configs method over HTTP. @@ -1313,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: ~.web_security_scanner.ListScanConfigsResponse: @@ -1324,6 +1770,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListScanConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_scan_configs( request, metadata ) @@ -1336,6 +1783,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1.WebSecurityScannerClient.ListScanConfigs", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "ListScanConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._ListScanConfigs._get_response( self._host, @@ -1356,7 +1830,31 @@ def __call__( pb_resp = web_security_scanner.ListScanConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_scan_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListScanConfigsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1.WebSecurityScannerClient.list_scan_configs", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "ListScanConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListScanRuns( @@ -1394,7 +1892,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListScanRunsResponse: r"""Call the list scan runs method over HTTP. @@ -1404,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: ~.web_security_scanner.ListScanRunsResponse: @@ -1415,6 +1915,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListScanRuns._get_http_options() ) + request, metadata = self._interceptor.pre_list_scan_runs(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseListScanRuns._get_transcoded_request( http_options, request @@ -1425,6 +1926,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1.WebSecurityScannerClient.ListScanRuns", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "ListScanRuns", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._ListScanRuns._get_response( self._host, @@ -1445,7 +1973,31 @@ def __call__( pb_resp = web_security_scanner.ListScanRunsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_scan_runs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListScanRunsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1.WebSecurityScannerClient.list_scan_runs", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "ListScanRuns", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StartScanRun( @@ -1484,7 +2036,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Call the start scan run method over HTTP. @@ -1494,8 +2046,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.scan_run.ScanRun: @@ -1508,6 +2062,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseStartScanRun._get_http_options() ) + request, metadata = self._interceptor.pre_start_scan_run(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseStartScanRun._get_transcoded_request( http_options, request @@ -1522,6 +2077,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1.WebSecurityScannerClient.StartScanRun", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "StartScanRun", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._StartScanRun._get_response( self._host, @@ -1543,7 +2125,29 @@ def __call__( pb_resp = scan_run.ScanRun.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_start_scan_run(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_run.ScanRun.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1.WebSecurityScannerClient.start_scan_run", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "StartScanRun", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StopScanRun( @@ -1582,7 +2186,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Call the stop scan run method over HTTP. @@ -1592,8 +2196,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.scan_run.ScanRun: @@ -1606,6 +2212,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseStopScanRun._get_http_options() ) + request, metadata = self._interceptor.pre_stop_scan_run(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseStopScanRun._get_transcoded_request( http_options, request @@ -1620,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.websecurityscanner_v1.WebSecurityScannerClient.StopScanRun", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "StopScanRun", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._StopScanRun._get_response( self._host, @@ -1641,7 +2275,29 @@ def __call__( pb_resp = scan_run.ScanRun.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_stop_scan_run(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_run.ScanRun.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1.WebSecurityScannerClient.stop_scan_run", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "StopScanRun", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateScanConfig( @@ -1680,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]]] = (), ) -> scan_config.ScanConfig: r"""Call the update scan config method over HTTP. @@ -1690,8 +2346,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.scan_config.ScanConfig: @@ -1703,6 +2361,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseUpdateScanConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_scan_config( request, metadata ) @@ -1719,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.websecurityscanner_v1.WebSecurityScannerClient.UpdateScanConfig", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "UpdateScanConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._UpdateScanConfig._get_response( self._host, @@ -1740,7 +2426,29 @@ def __call__( pb_resp = scan_config.ScanConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_scan_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_config.ScanConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1.WebSecurityScannerClient.update_scan_config", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "UpdateScanConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/gapic_version.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/gapic_version.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/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-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/async_client.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/async_client.py index 3e9450a8b77b..782b07f86ef5 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/async_client.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/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, WebSecurityScannerTransport from .transports.grpc_asyncio import WebSecurityScannerGrpcAsyncIOTransport +try: + from google.api_core import client_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 WebSecurityScannerAsyncClient: """Cloud Web Security Scanner Service identifies security @@ -279,6 +289,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.websecurityscanner_v1alpha.WebSecurityScannerAsyncClient`.", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "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.websecurityscanner.v1alpha.WebSecurityScanner", + "credentialsType": None, + }, + ) + async def create_scan_config( self, request: Optional[ @@ -289,7 +321,7 @@ async def create_scan_config( scan_config: Optional[gcw_scan_config.ScanConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcw_scan_config.ScanConfig: r"""Creates a new ScanConfig. @@ -346,8 +378,10 @@ async def sample_create_scan_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.cloud.websecurityscanner_v1alpha.types.ScanConfig: @@ -413,7 +447,7 @@ async def delete_scan_config( name: Optional[str] = None, retry: OptionalRetry = 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 an existing ScanConfig and its child resources. @@ -456,8 +490,10 @@ async def sample_delete_scan_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -511,7 +547,7 @@ async def get_scan_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Gets a ScanConfig. @@ -556,8 +592,10 @@ async def sample_get_scan_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.cloud.websecurityscanner_v1alpha.types.ScanConfig: @@ -621,7 +659,7 @@ async def list_scan_configs( 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.ListScanConfigsAsyncPager: r"""Lists ScanConfigs under a given project. @@ -666,8 +704,10 @@ async def sample_list_scan_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.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListScanConfigsAsyncPager: @@ -744,7 +784,7 @@ async def update_scan_config( 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]]] = (), ) -> gcw_scan_config.ScanConfig: r"""Updates a ScanConfig. This method support partial update of a ScanConfig. @@ -803,8 +843,10 @@ async def sample_update_scan_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.cloud.websecurityscanner_v1alpha.types.ScanConfig: @@ -870,7 +912,7 @@ async def start_scan_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Start a ScanRun according to the given ScanConfig. @@ -915,8 +957,10 @@ async def sample_start_scan_run(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1alpha.types.ScanRun: @@ -977,7 +1021,7 @@ async def get_scan_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Gets a ScanRun. @@ -1022,8 +1066,10 @@ async def sample_get_scan_run(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1alpha.types.ScanRun: @@ -1084,7 +1130,7 @@ async def list_scan_runs( 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.ListScanRunsAsyncPager: r"""Lists ScanRuns under a given ScanConfig, in descending order of ScanRun stop time. @@ -1131,8 +1177,10 @@ async def sample_list_scan_runs(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListScanRunsAsyncPager: @@ -1206,7 +1254,7 @@ async def stop_scan_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Stops a ScanRun. The stopped ScanRun is returned. @@ -1251,8 +1299,10 @@ async def sample_stop_scan_run(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1alpha.types.ScanRun: @@ -1315,7 +1365,7 @@ async def list_crawled_urls( 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.ListCrawledUrlsAsyncPager: r"""List CrawledUrls under a given ScanRun. @@ -1361,8 +1411,10 @@ async def sample_list_crawled_urls(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListCrawledUrlsAsyncPager: @@ -1436,7 +1488,7 @@ async def get_finding( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Gets a Finding. @@ -1481,8 +1533,10 @@ async def sample_get_finding(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1alpha.types.Finding: @@ -1545,7 +1599,7 @@ async def list_findings( 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.ListFindingsAsyncPager: r"""List Findings under a given ScanRun. @@ -1600,8 +1654,10 @@ async def sample_list_findings(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListFindingsAsyncPager: @@ -1679,7 +1735,7 @@ async def list_finding_type_stats( 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]]] = (), ) -> web_security_scanner.ListFindingTypeStatsResponse: r"""List all FindingTypeStats under a given ScanRun. @@ -1724,8 +1780,10 @@ async def sample_list_finding_type_stats(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1alpha.types.ListFindingTypeStatsResponse: diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/client.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/client.py index 788e913ff307..71a7637efedc 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/client.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/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 @@ -642,6 +652,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( @@ -708,6 +722,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.websecurityscanner_v1alpha.WebSecurityScannerClient`.", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "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.websecurityscanner.v1alpha.WebSecurityScanner", + "credentialsType": None, + }, + ) + def create_scan_config( self, request: Optional[ @@ -718,7 +755,7 @@ def create_scan_config( scan_config: Optional[gcw_scan_config.ScanConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcw_scan_config.ScanConfig: r"""Creates a new ScanConfig. @@ -775,8 +812,10 @@ def sample_create_scan_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.websecurityscanner_v1alpha.types.ScanConfig: @@ -839,7 +878,7 @@ def delete_scan_config( name: Optional[str] = None, retry: OptionalRetry = 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 an existing ScanConfig and its child resources. @@ -882,8 +921,10 @@ def sample_delete_scan_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -934,7 +975,7 @@ def get_scan_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Gets a ScanConfig. @@ -979,8 +1020,10 @@ def sample_get_scan_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.websecurityscanner_v1alpha.types.ScanConfig: @@ -1041,7 +1084,7 @@ def list_scan_configs( 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.ListScanConfigsPager: r"""Lists ScanConfigs under a given project. @@ -1086,8 +1129,10 @@ def sample_list_scan_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.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListScanConfigsPager: @@ -1161,7 +1206,7 @@ def update_scan_config( 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]]] = (), ) -> gcw_scan_config.ScanConfig: r"""Updates a ScanConfig. This method support partial update of a ScanConfig. @@ -1220,8 +1265,10 @@ def sample_update_scan_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.websecurityscanner_v1alpha.types.ScanConfig: @@ -1284,7 +1331,7 @@ def start_scan_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Start a ScanRun according to the given ScanConfig. @@ -1329,8 +1376,10 @@ def sample_start_scan_run(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1alpha.types.ScanRun: @@ -1388,7 +1437,7 @@ def get_scan_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Gets a ScanRun. @@ -1433,8 +1482,10 @@ def sample_get_scan_run(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1alpha.types.ScanRun: @@ -1492,7 +1543,7 @@ def list_scan_runs( 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.ListScanRunsPager: r"""Lists ScanRuns under a given ScanConfig, in descending order of ScanRun stop time. @@ -1539,8 +1590,10 @@ def sample_list_scan_runs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListScanRunsPager: @@ -1611,7 +1664,7 @@ def stop_scan_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Stops a ScanRun. The stopped ScanRun is returned. @@ -1656,8 +1709,10 @@ def sample_stop_scan_run(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1alpha.types.ScanRun: @@ -1717,7 +1772,7 @@ def list_crawled_urls( 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.ListCrawledUrlsPager: r"""List CrawledUrls under a given ScanRun. @@ -1763,8 +1818,10 @@ def sample_list_crawled_urls(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListCrawledUrlsPager: @@ -1835,7 +1892,7 @@ def get_finding( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Gets a Finding. @@ -1880,8 +1937,10 @@ def sample_get_finding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1alpha.types.Finding: @@ -1941,7 +2000,7 @@ def list_findings( 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.ListFindingsPager: r"""List Findings under a given ScanRun. @@ -1996,8 +2055,10 @@ def sample_list_findings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListFindingsPager: @@ -2072,7 +2133,7 @@ def list_finding_type_stats( 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]]] = (), ) -> web_security_scanner.ListFindingTypeStatsResponse: r"""List all FindingTypeStats under a given ScanRun. @@ -2117,8 +2178,10 @@ def sample_list_finding_type_stats(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1alpha.types.ListFindingTypeStatsResponse: diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/pagers.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/pagers.py index bc732c3edd4f..90f9902f9060 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/pagers.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/pagers.py @@ -73,7 +73,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -87,8 +87,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = web_security_scanner.ListScanConfigsRequest(request) @@ -147,7 +149,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. @@ -161,8 +163,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 = web_security_scanner.ListScanConfigsRequest(request) @@ -227,7 +231,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -241,8 +245,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = web_security_scanner.ListScanRunsRequest(request) @@ -301,7 +307,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. @@ -315,8 +321,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 = web_security_scanner.ListScanRunsRequest(request) @@ -379,7 +387,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -393,8 +401,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = web_security_scanner.ListCrawledUrlsRequest(request) @@ -453,7 +463,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. @@ -467,8 +477,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 = web_security_scanner.ListCrawledUrlsRequest(request) @@ -533,7 +545,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -547,8 +559,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = web_security_scanner.ListFindingsRequest(request) @@ -607,7 +621,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. @@ -621,8 +635,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 = web_security_scanner.ListFindingsRequest(request) diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc.py index 765356d4a10a..7dab5292ce29 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/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.cloud.websecurityscanner_v1alpha.types import scan_run, web_security_scanner from google.cloud.websecurityscanner_v1alpha.types import scan_config as gcw_scan_config @@ -30,6 +36,81 @@ from .base import DEFAULT_CLIENT_INFO, WebSecurityScannerTransport +try: + from google.api_core import client_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.websecurityscanner.v1alpha.WebSecurityScanner", + "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.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WebSecurityScannerGrpcTransport(WebSecurityScannerTransport): """gRPC backend transport for WebSecurityScanner. @@ -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 @@ -262,7 +348,7 @@ def create_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_scan_config" not in self._stubs: - self._stubs["create_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["create_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/CreateScanConfig", request_serializer=web_security_scanner.CreateScanConfigRequest.serialize, response_deserializer=gcw_scan_config.ScanConfig.deserialize, @@ -289,7 +375,7 @@ def delete_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_scan_config" not in self._stubs: - self._stubs["delete_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/DeleteScanConfig", request_serializer=web_security_scanner.DeleteScanConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -315,7 +401,7 @@ def get_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_scan_config" not in self._stubs: - self._stubs["get_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["get_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/GetScanConfig", request_serializer=web_security_scanner.GetScanConfigRequest.serialize, response_deserializer=scan_config.ScanConfig.deserialize, @@ -344,7 +430,7 @@ def list_scan_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_scan_configs" not in self._stubs: - self._stubs["list_scan_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_scan_configs"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListScanConfigs", request_serializer=web_security_scanner.ListScanConfigsRequest.serialize, response_deserializer=web_security_scanner.ListScanConfigsResponse.deserialize, @@ -373,7 +459,7 @@ def update_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_scan_config" not in self._stubs: - self._stubs["update_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["update_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/UpdateScanConfig", request_serializer=web_security_scanner.UpdateScanConfigRequest.serialize, response_deserializer=gcw_scan_config.ScanConfig.deserialize, @@ -399,7 +485,7 @@ def start_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_scan_run" not in self._stubs: - self._stubs["start_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["start_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/StartScanRun", request_serializer=web_security_scanner.StartScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -425,7 +511,7 @@ def get_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_scan_run" not in self._stubs: - self._stubs["get_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["get_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/GetScanRun", request_serializer=web_security_scanner.GetScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -455,7 +541,7 @@ def list_scan_runs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_scan_runs" not in self._stubs: - self._stubs["list_scan_runs"] = self.grpc_channel.unary_unary( + self._stubs["list_scan_runs"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListScanRuns", request_serializer=web_security_scanner.ListScanRunsRequest.serialize, response_deserializer=web_security_scanner.ListScanRunsResponse.deserialize, @@ -481,7 +567,7 @@ def stop_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_scan_run" not in self._stubs: - self._stubs["stop_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["stop_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/StopScanRun", request_serializer=web_security_scanner.StopScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -510,7 +596,7 @@ def list_crawled_urls( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_crawled_urls" not in self._stubs: - self._stubs["list_crawled_urls"] = self.grpc_channel.unary_unary( + self._stubs["list_crawled_urls"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListCrawledUrls", request_serializer=web_security_scanner.ListCrawledUrlsRequest.serialize, response_deserializer=web_security_scanner.ListCrawledUrlsResponse.deserialize, @@ -536,7 +622,7 @@ def get_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_finding" not in self._stubs: - self._stubs["get_finding"] = self.grpc_channel.unary_unary( + self._stubs["get_finding"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/GetFinding", request_serializer=web_security_scanner.GetFindingRequest.serialize, response_deserializer=finding.Finding.deserialize, @@ -565,7 +651,7 @@ def list_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_findings" not in self._stubs: - self._stubs["list_findings"] = self.grpc_channel.unary_unary( + self._stubs["list_findings"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListFindings", request_serializer=web_security_scanner.ListFindingsRequest.serialize, response_deserializer=web_security_scanner.ListFindingsResponse.deserialize, @@ -594,7 +680,7 @@ def list_finding_type_stats( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_finding_type_stats" not in self._stubs: - self._stubs["list_finding_type_stats"] = self.grpc_channel.unary_unary( + self._stubs["list_finding_type_stats"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListFindingTypeStats", request_serializer=web_security_scanner.ListFindingTypeStatsRequest.serialize, response_deserializer=web_security_scanner.ListFindingTypeStatsResponse.deserialize, @@ -602,7 +688,7 @@ def list_finding_type_stats( return self._stubs["list_finding_type_stats"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc_asyncio.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc_asyncio.py index b442532d19e2..310814a48787 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc_asyncio.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/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.cloud.websecurityscanner_v1alpha.types import scan_run, web_security_scanner from google.cloud.websecurityscanner_v1alpha.types import scan_config as gcw_scan_config @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, WebSecurityScannerTransport from .grpc import WebSecurityScannerGrpcTransport +try: + from google.api_core import client_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.websecurityscanner.v1alpha.WebSecurityScanner", + "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.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WebSecurityScannerGrpcAsyncIOTransport(WebSecurityScannerTransport): """gRPC AsyncIO backend transport for WebSecurityScanner. @@ -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 @@ -271,7 +356,7 @@ def create_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_scan_config" not in self._stubs: - self._stubs["create_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["create_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/CreateScanConfig", request_serializer=web_security_scanner.CreateScanConfigRequest.serialize, response_deserializer=gcw_scan_config.ScanConfig.deserialize, @@ -300,7 +385,7 @@ def delete_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_scan_config" not in self._stubs: - self._stubs["delete_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/DeleteScanConfig", request_serializer=web_security_scanner.DeleteScanConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -328,7 +413,7 @@ def get_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_scan_config" not in self._stubs: - self._stubs["get_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["get_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/GetScanConfig", request_serializer=web_security_scanner.GetScanConfigRequest.serialize, response_deserializer=scan_config.ScanConfig.deserialize, @@ -357,7 +442,7 @@ def list_scan_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_scan_configs" not in self._stubs: - self._stubs["list_scan_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_scan_configs"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListScanConfigs", request_serializer=web_security_scanner.ListScanConfigsRequest.serialize, response_deserializer=web_security_scanner.ListScanConfigsResponse.deserialize, @@ -387,7 +472,7 @@ def update_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_scan_config" not in self._stubs: - self._stubs["update_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["update_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/UpdateScanConfig", request_serializer=web_security_scanner.UpdateScanConfigRequest.serialize, response_deserializer=gcw_scan_config.ScanConfig.deserialize, @@ -415,7 +500,7 @@ def start_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_scan_run" not in self._stubs: - self._stubs["start_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["start_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/StartScanRun", request_serializer=web_security_scanner.StartScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -443,7 +528,7 @@ def get_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_scan_run" not in self._stubs: - self._stubs["get_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["get_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/GetScanRun", request_serializer=web_security_scanner.GetScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -473,7 +558,7 @@ def list_scan_runs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_scan_runs" not in self._stubs: - self._stubs["list_scan_runs"] = self.grpc_channel.unary_unary( + self._stubs["list_scan_runs"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListScanRuns", request_serializer=web_security_scanner.ListScanRunsRequest.serialize, response_deserializer=web_security_scanner.ListScanRunsResponse.deserialize, @@ -501,7 +586,7 @@ def stop_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_scan_run" not in self._stubs: - self._stubs["stop_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["stop_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/StopScanRun", request_serializer=web_security_scanner.StopScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -530,7 +615,7 @@ def list_crawled_urls( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_crawled_urls" not in self._stubs: - self._stubs["list_crawled_urls"] = self.grpc_channel.unary_unary( + self._stubs["list_crawled_urls"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListCrawledUrls", request_serializer=web_security_scanner.ListCrawledUrlsRequest.serialize, response_deserializer=web_security_scanner.ListCrawledUrlsResponse.deserialize, @@ -556,7 +641,7 @@ def get_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_finding" not in self._stubs: - self._stubs["get_finding"] = self.grpc_channel.unary_unary( + self._stubs["get_finding"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/GetFinding", request_serializer=web_security_scanner.GetFindingRequest.serialize, response_deserializer=finding.Finding.deserialize, @@ -585,7 +670,7 @@ def list_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_findings" not in self._stubs: - self._stubs["list_findings"] = self.grpc_channel.unary_unary( + self._stubs["list_findings"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListFindings", request_serializer=web_security_scanner.ListFindingsRequest.serialize, response_deserializer=web_security_scanner.ListFindingsResponse.deserialize, @@ -614,7 +699,7 @@ def list_finding_type_stats( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_finding_type_stats" not in self._stubs: - self._stubs["list_finding_type_stats"] = self.grpc_channel.unary_unary( + self._stubs["list_finding_type_stats"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListFindingTypeStats", request_serializer=web_security_scanner.ListFindingTypeStatsRequest.serialize, response_deserializer=web_security_scanner.ListFindingTypeStatsResponse.deserialize, @@ -787,7 +872,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-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/rest.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/rest.py index a3f21e7077c7..b3ab17f88981 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/rest.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/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, @@ -173,8 +181,11 @@ def post_update_scan_config(self, response): def pre_create_scan_config( self, request: web_security_scanner.CreateScanConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.CreateScanConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.CreateScanConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_scan_config Override in a subclass to manipulate the request or metadata @@ -196,8 +207,11 @@ def post_create_scan_config( def pre_delete_scan_config( self, request: web_security_scanner.DeleteScanConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.DeleteScanConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.DeleteScanConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_scan_config Override in a subclass to manipulate the request or metadata @@ -208,8 +222,10 @@ def pre_delete_scan_config( def pre_get_finding( self, request: web_security_scanner.GetFindingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.GetFindingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.GetFindingRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_finding Override in a subclass to manipulate the request or metadata @@ -229,8 +245,11 @@ def post_get_finding(self, response: finding.Finding) -> finding.Finding: def pre_get_scan_config( self, request: web_security_scanner.GetScanConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.GetScanConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.GetScanConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_scan_config Override in a subclass to manipulate the request or metadata @@ -252,8 +271,10 @@ def post_get_scan_config( def pre_get_scan_run( self, request: web_security_scanner.GetScanRunRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.GetScanRunRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.GetScanRunRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_scan_run Override in a subclass to manipulate the request or metadata @@ -273,8 +294,11 @@ def post_get_scan_run(self, response: scan_run.ScanRun) -> scan_run.ScanRun: def pre_list_crawled_urls( self, request: web_security_scanner.ListCrawledUrlsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.ListCrawledUrlsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.ListCrawledUrlsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_crawled_urls Override in a subclass to manipulate the request or metadata @@ -296,8 +320,11 @@ def post_list_crawled_urls( def pre_list_findings( self, request: web_security_scanner.ListFindingsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.ListFindingsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.ListFindingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_findings Override in a subclass to manipulate the request or metadata @@ -319,9 +346,10 @@ def post_list_findings( def pre_list_finding_type_stats( self, request: web_security_scanner.ListFindingTypeStatsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - web_security_scanner.ListFindingTypeStatsRequest, Sequence[Tuple[str, str]] + web_security_scanner.ListFindingTypeStatsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_finding_type_stats @@ -344,8 +372,11 @@ def post_list_finding_type_stats( def pre_list_scan_configs( self, request: web_security_scanner.ListScanConfigsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.ListScanConfigsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.ListScanConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_scan_configs Override in a subclass to manipulate the request or metadata @@ -367,8 +398,11 @@ def post_list_scan_configs( def pre_list_scan_runs( self, request: web_security_scanner.ListScanRunsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.ListScanRunsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.ListScanRunsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_scan_runs Override in a subclass to manipulate the request or metadata @@ -390,8 +424,11 @@ def post_list_scan_runs( def pre_start_scan_run( self, request: web_security_scanner.StartScanRunRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.StartScanRunRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.StartScanRunRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for start_scan_run Override in a subclass to manipulate the request or metadata @@ -411,8 +448,10 @@ def post_start_scan_run(self, response: scan_run.ScanRun) -> scan_run.ScanRun: def pre_stop_scan_run( self, request: web_security_scanner.StopScanRunRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.StopScanRunRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.StopScanRunRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for stop_scan_run Override in a subclass to manipulate the request or metadata @@ -432,8 +471,11 @@ def post_stop_scan_run(self, response: scan_run.ScanRun) -> scan_run.ScanRun: def pre_update_scan_config( self, request: web_security_scanner.UpdateScanConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.UpdateScanConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.UpdateScanConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_scan_config Override in a subclass to manipulate the request or metadata @@ -578,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]]] = (), ) -> gcw_scan_config.ScanConfig: r"""Call the create scan config method over HTTP. @@ -588,8 +630,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gcw_scan_config.ScanConfig: @@ -602,6 +646,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseCreateScanConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_scan_config( request, metadata ) @@ -618,6 +663,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1alpha.WebSecurityScannerClient.CreateScanConfig", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "CreateScanConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._CreateScanConfig._get_response( self._host, @@ -639,7 +711,29 @@ def __call__( pb_resp = gcw_scan_config.ScanConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_scan_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcw_scan_config.ScanConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1alpha.WebSecurityScannerClient.create_scan_config", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "CreateScanConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteScanConfig( @@ -677,7 +771,7 @@ 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 scan config method over HTTP. @@ -687,13 +781,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 = ( _BaseWebSecurityScannerRestTransport._BaseDeleteScanConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_scan_config( request, metadata ) @@ -706,6 +803,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1alpha.WebSecurityScannerClient.DeleteScanConfig", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "DeleteScanConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._DeleteScanConfig._get_response( self._host, @@ -755,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]]] = (), ) -> finding.Finding: r"""Call the get finding method over HTTP. @@ -765,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: ~.finding.Finding: @@ -779,6 +905,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseGetFinding._get_http_options() ) + request, metadata = self._interceptor.pre_get_finding(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseGetFinding._get_transcoded_request( http_options, request @@ -789,6 +916,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1alpha.WebSecurityScannerClient.GetFinding", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "GetFinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._GetFinding._get_response( self._host, @@ -809,7 +963,29 @@ def __call__( pb_resp = finding.Finding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_finding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = finding.Finding.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1alpha.WebSecurityScannerClient.get_finding", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "GetFinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetScanConfig( @@ -847,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]]] = (), ) -> scan_config.ScanConfig: r"""Call the get scan config method over HTTP. @@ -857,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: ~.scan_config.ScanConfig: @@ -871,6 +1049,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseGetScanConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_scan_config(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseGetScanConfig._get_transcoded_request( http_options, request @@ -881,6 +1060,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1alpha.WebSecurityScannerClient.GetScanConfig", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "GetScanConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._GetScanConfig._get_response( self._host, @@ -901,7 +1107,29 @@ def __call__( pb_resp = scan_config.ScanConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_scan_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_config.ScanConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1alpha.WebSecurityScannerClient.get_scan_config", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "GetScanConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetScanRun( @@ -938,7 +1166,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Call the get scan run method over HTTP. @@ -948,8 +1176,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.scan_run.ScanRun: @@ -961,6 +1191,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseGetScanRun._get_http_options() ) + request, metadata = self._interceptor.pre_get_scan_run(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseGetScanRun._get_transcoded_request( http_options, request @@ -971,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.websecurityscanner_v1alpha.WebSecurityScannerClient.GetScanRun", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "GetScanRun", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._GetScanRun._get_response( self._host, @@ -991,7 +1249,29 @@ def __call__( pb_resp = scan_run.ScanRun.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_scan_run(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_run.ScanRun.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1alpha.WebSecurityScannerClient.get_scan_run", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "GetScanRun", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCrawledUrls( @@ -1029,7 +1309,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListCrawledUrlsResponse: r"""Call the list crawled urls method over HTTP. @@ -1039,8 +1319,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.web_security_scanner.ListCrawledUrlsResponse: @@ -1050,6 +1332,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListCrawledUrls._get_http_options() ) + request, metadata = self._interceptor.pre_list_crawled_urls( request, metadata ) @@ -1062,6 +1345,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1alpha.WebSecurityScannerClient.ListCrawledUrls", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "ListCrawledUrls", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._ListCrawledUrls._get_response( self._host, @@ -1082,7 +1392,31 @@ def __call__( pb_resp = web_security_scanner.ListCrawledUrlsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_crawled_urls(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListCrawledUrlsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1alpha.WebSecurityScannerClient.list_crawled_urls", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "ListCrawledUrls", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListFindings( @@ -1120,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]]] = (), ) -> web_security_scanner.ListFindingsResponse: r"""Call the list findings method over HTTP. @@ -1130,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: ~.web_security_scanner.ListFindingsResponse: @@ -1141,6 +1477,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListFindings._get_http_options() ) + request, metadata = self._interceptor.pre_list_findings(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseListFindings._get_transcoded_request( http_options, request @@ -1151,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.websecurityscanner_v1alpha.WebSecurityScannerClient.ListFindings", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "ListFindings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._ListFindings._get_response( self._host, @@ -1171,7 +1535,31 @@ def __call__( pb_resp = web_security_scanner.ListFindingsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_findings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListFindingsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1alpha.WebSecurityScannerClient.list_findings", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "ListFindings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListFindingTypeStats( @@ -1209,7 +1597,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListFindingTypeStatsResponse: r"""Call the list finding type stats method over HTTP. @@ -1219,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: ~.web_security_scanner.ListFindingTypeStatsResponse: @@ -1230,6 +1620,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListFindingTypeStats._get_http_options() ) + request, metadata = self._interceptor.pre_list_finding_type_stats( request, metadata ) @@ -1242,6 +1633,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1alpha.WebSecurityScannerClient.ListFindingTypeStats", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "ListFindingTypeStats", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( WebSecurityScannerRestTransport._ListFindingTypeStats._get_response( @@ -1264,7 +1682,33 @@ def __call__( pb_resp = web_security_scanner.ListFindingTypeStatsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_finding_type_stats(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListFindingTypeStatsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1alpha.WebSecurityScannerClient.list_finding_type_stats", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "ListFindingTypeStats", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListScanConfigs( @@ -1302,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]]] = (), ) -> web_security_scanner.ListScanConfigsResponse: r"""Call the list scan configs method over HTTP. @@ -1312,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: ~.web_security_scanner.ListScanConfigsResponse: @@ -1323,6 +1769,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListScanConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_scan_configs( request, metadata ) @@ -1335,6 +1782,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1alpha.WebSecurityScannerClient.ListScanConfigs", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "ListScanConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._ListScanConfigs._get_response( self._host, @@ -1355,7 +1829,31 @@ def __call__( pb_resp = web_security_scanner.ListScanConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_scan_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListScanConfigsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1alpha.WebSecurityScannerClient.list_scan_configs", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "ListScanConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListScanRuns( @@ -1393,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]]] = (), ) -> web_security_scanner.ListScanRunsResponse: r"""Call the list scan runs method over HTTP. @@ -1403,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: ~.web_security_scanner.ListScanRunsResponse: @@ -1414,6 +1914,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListScanRuns._get_http_options() ) + request, metadata = self._interceptor.pre_list_scan_runs(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseListScanRuns._get_transcoded_request( http_options, request @@ -1424,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 = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1alpha.WebSecurityScannerClient.ListScanRuns", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "ListScanRuns", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._ListScanRuns._get_response( self._host, @@ -1444,7 +1972,31 @@ def __call__( pb_resp = web_security_scanner.ListScanRunsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_scan_runs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListScanRunsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1alpha.WebSecurityScannerClient.list_scan_runs", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "ListScanRuns", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StartScanRun( @@ -1483,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]]] = (), ) -> scan_run.ScanRun: r"""Call the start scan run method over HTTP. @@ -1493,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: ~.scan_run.ScanRun: @@ -1506,6 +2060,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseStartScanRun._get_http_options() ) + request, metadata = self._interceptor.pre_start_scan_run(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseStartScanRun._get_transcoded_request( http_options, request @@ -1520,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.websecurityscanner_v1alpha.WebSecurityScannerClient.StartScanRun", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "StartScanRun", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._StartScanRun._get_response( self._host, @@ -1541,7 +2123,29 @@ def __call__( pb_resp = scan_run.ScanRun.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_start_scan_run(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_run.ScanRun.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1alpha.WebSecurityScannerClient.start_scan_run", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "StartScanRun", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StopScanRun( @@ -1580,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]]] = (), ) -> scan_run.ScanRun: r"""Call the stop scan run method over HTTP. @@ -1590,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: ~.scan_run.ScanRun: @@ -1603,6 +2209,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseStopScanRun._get_http_options() ) + request, metadata = self._interceptor.pre_stop_scan_run(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseStopScanRun._get_transcoded_request( http_options, request @@ -1617,6 +2224,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1alpha.WebSecurityScannerClient.StopScanRun", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "StopScanRun", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._StopScanRun._get_response( self._host, @@ -1638,7 +2272,29 @@ def __call__( pb_resp = scan_run.ScanRun.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_stop_scan_run(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_run.ScanRun.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1alpha.WebSecurityScannerClient.stop_scan_run", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "StopScanRun", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateScanConfig( @@ -1677,7 +2333,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcw_scan_config.ScanConfig: r"""Call the update scan config method over HTTP. @@ -1687,8 +2343,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gcw_scan_config.ScanConfig: @@ -1701,6 +2359,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseUpdateScanConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_scan_config( request, metadata ) @@ -1717,6 +2376,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1alpha.WebSecurityScannerClient.UpdateScanConfig", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "UpdateScanConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._UpdateScanConfig._get_response( self._host, @@ -1738,7 +2424,29 @@ def __call__( pb_resp = gcw_scan_config.ScanConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_scan_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcw_scan_config.ScanConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1alpha.WebSecurityScannerClient.update_scan_config", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "UpdateScanConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/gapic_version.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/gapic_version.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/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-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/async_client.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/async_client.py index f3b106ac2584..5994224367ff 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/async_client.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/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, WebSecurityScannerTransport from .transports.grpc_asyncio import WebSecurityScannerGrpcAsyncIOTransport +try: + from google.api_core import client_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 WebSecurityScannerAsyncClient: """Cloud Web Security Scanner Service identifies security @@ -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.websecurityscanner_v1beta.WebSecurityScannerAsyncClient`.", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "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.websecurityscanner.v1beta.WebSecurityScanner", + "credentialsType": None, + }, + ) + async def create_scan_config( self, request: Optional[ @@ -294,7 +326,7 @@ async def create_scan_config( scan_config: Optional[gcw_scan_config.ScanConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcw_scan_config.ScanConfig: r"""Creates a new ScanConfig. @@ -351,8 +383,10 @@ async def sample_create_scan_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.cloud.websecurityscanner_v1beta.types.ScanConfig: @@ -417,7 +451,7 @@ async def delete_scan_config( name: Optional[str] = None, retry: OptionalRetry = 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 an existing ScanConfig and its child resources. @@ -460,8 +494,10 @@ async def sample_delete_scan_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -515,7 +551,7 @@ async def get_scan_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Gets a ScanConfig. @@ -560,8 +596,10 @@ async def sample_get_scan_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.cloud.websecurityscanner_v1beta.types.ScanConfig: @@ -624,7 +662,7 @@ async def list_scan_configs( 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.ListScanConfigsAsyncPager: r"""Lists ScanConfigs under a given project. @@ -669,8 +707,10 @@ async def sample_list_scan_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.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListScanConfigsAsyncPager: @@ -747,7 +787,7 @@ async def update_scan_config( 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]]] = (), ) -> gcw_scan_config.ScanConfig: r"""Updates a ScanConfig. This method support partial update of a ScanConfig. @@ -806,8 +846,10 @@ async def sample_update_scan_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.cloud.websecurityscanner_v1beta.types.ScanConfig: @@ -872,7 +914,7 @@ async def start_scan_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Start a ScanRun according to the given ScanConfig. @@ -917,8 +959,10 @@ async def sample_start_scan_run(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1beta.types.ScanRun: @@ -980,7 +1024,7 @@ async def get_scan_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Gets a ScanRun. @@ -1025,8 +1069,10 @@ async def sample_get_scan_run(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1beta.types.ScanRun: @@ -1088,7 +1134,7 @@ async def list_scan_runs( 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.ListScanRunsAsyncPager: r"""Lists ScanRuns under a given ScanConfig, in descending order of ScanRun stop time. @@ -1135,8 +1181,10 @@ async def sample_list_scan_runs(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListScanRunsAsyncPager: @@ -1210,7 +1258,7 @@ async def stop_scan_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Stops a ScanRun. The stopped ScanRun is returned. @@ -1255,8 +1303,10 @@ async def sample_stop_scan_run(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1beta.types.ScanRun: @@ -1320,7 +1370,7 @@ async def list_crawled_urls( 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.ListCrawledUrlsAsyncPager: r"""List CrawledUrls under a given ScanRun. @@ -1366,8 +1416,10 @@ async def sample_list_crawled_urls(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListCrawledUrlsAsyncPager: @@ -1441,7 +1493,7 @@ async def get_finding( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Gets a Finding. @@ -1486,8 +1538,10 @@ async def sample_get_finding(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1beta.types.Finding: @@ -1550,7 +1604,7 @@ async def list_findings( 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.ListFindingsAsyncPager: r"""List Findings under a given ScanRun. @@ -1605,8 +1659,10 @@ async def sample_list_findings(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListFindingsAsyncPager: @@ -1684,7 +1740,7 @@ async def list_finding_type_stats( 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]]] = (), ) -> web_security_scanner.ListFindingTypeStatsResponse: r"""List all FindingTypeStats under a given ScanRun. @@ -1729,8 +1785,10 @@ async def sample_list_finding_type_stats(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1beta.types.ListFindingTypeStatsResponse: diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/client.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/client.py index 062ed4055350..5da5353fd2dc 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/client.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/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 @@ -647,6 +657,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( @@ -713,6 +727,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.websecurityscanner_v1beta.WebSecurityScannerClient`.", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "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.websecurityscanner.v1beta.WebSecurityScanner", + "credentialsType": None, + }, + ) + def create_scan_config( self, request: Optional[ @@ -723,7 +760,7 @@ def create_scan_config( scan_config: Optional[gcw_scan_config.ScanConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcw_scan_config.ScanConfig: r"""Creates a new ScanConfig. @@ -780,8 +817,10 @@ def sample_create_scan_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.websecurityscanner_v1beta.types.ScanConfig: @@ -843,7 +882,7 @@ def delete_scan_config( name: Optional[str] = None, retry: OptionalRetry = 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 an existing ScanConfig and its child resources. @@ -886,8 +925,10 @@ def sample_delete_scan_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -938,7 +979,7 @@ def get_scan_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Gets a ScanConfig. @@ -983,8 +1024,10 @@ def sample_get_scan_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.websecurityscanner_v1beta.types.ScanConfig: @@ -1044,7 +1087,7 @@ def list_scan_configs( 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.ListScanConfigsPager: r"""Lists ScanConfigs under a given project. @@ -1089,8 +1132,10 @@ def sample_list_scan_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.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListScanConfigsPager: @@ -1164,7 +1209,7 @@ def update_scan_config( 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]]] = (), ) -> gcw_scan_config.ScanConfig: r"""Updates a ScanConfig. This method support partial update of a ScanConfig. @@ -1223,8 +1268,10 @@ def sample_update_scan_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.websecurityscanner_v1beta.types.ScanConfig: @@ -1286,7 +1333,7 @@ def start_scan_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Start a ScanRun according to the given ScanConfig. @@ -1331,8 +1378,10 @@ def sample_start_scan_run(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1beta.types.ScanRun: @@ -1391,7 +1440,7 @@ def get_scan_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Gets a ScanRun. @@ -1436,8 +1485,10 @@ def sample_get_scan_run(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1beta.types.ScanRun: @@ -1496,7 +1547,7 @@ def list_scan_runs( 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.ListScanRunsPager: r"""Lists ScanRuns under a given ScanConfig, in descending order of ScanRun stop time. @@ -1543,8 +1594,10 @@ def sample_list_scan_runs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListScanRunsPager: @@ -1615,7 +1668,7 @@ def stop_scan_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Stops a ScanRun. The stopped ScanRun is returned. @@ -1660,8 +1713,10 @@ def sample_stop_scan_run(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1beta.types.ScanRun: @@ -1722,7 +1777,7 @@ def list_crawled_urls( 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.ListCrawledUrlsPager: r"""List CrawledUrls under a given ScanRun. @@ -1768,8 +1823,10 @@ def sample_list_crawled_urls(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListCrawledUrlsPager: @@ -1840,7 +1897,7 @@ def get_finding( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Gets a Finding. @@ -1885,8 +1942,10 @@ def sample_get_finding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1beta.types.Finding: @@ -1946,7 +2005,7 @@ def list_findings( 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.ListFindingsPager: r"""List Findings under a given ScanRun. @@ -2001,8 +2060,10 @@ def sample_list_findings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListFindingsPager: @@ -2077,7 +2138,7 @@ def list_finding_type_stats( 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]]] = (), ) -> web_security_scanner.ListFindingTypeStatsResponse: r"""List all FindingTypeStats under a given ScanRun. @@ -2122,8 +2183,10 @@ def sample_list_finding_type_stats(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.websecurityscanner_v1beta.types.ListFindingTypeStatsResponse: diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/pagers.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/pagers.py index f0afb9ae5ca7..30afc61e3aa4 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/pagers.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/pagers.py @@ -73,7 +73,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -87,8 +87,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = web_security_scanner.ListScanConfigsRequest(request) @@ -147,7 +149,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. @@ -161,8 +163,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 = web_security_scanner.ListScanConfigsRequest(request) @@ -227,7 +231,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -241,8 +245,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = web_security_scanner.ListScanRunsRequest(request) @@ -301,7 +307,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. @@ -315,8 +321,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 = web_security_scanner.ListScanRunsRequest(request) @@ -379,7 +387,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -393,8 +401,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = web_security_scanner.ListCrawledUrlsRequest(request) @@ -453,7 +463,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. @@ -467,8 +477,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 = web_security_scanner.ListCrawledUrlsRequest(request) @@ -533,7 +545,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -547,8 +559,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = web_security_scanner.ListFindingsRequest(request) @@ -607,7 +621,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. @@ -621,8 +635,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 = web_security_scanner.ListFindingsRequest(request) diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc.py index 0de4851178f2..c46489c05b12 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/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.cloud.websecurityscanner_v1beta.types import scan_run, web_security_scanner from google.cloud.websecurityscanner_v1beta.types import scan_config as gcw_scan_config @@ -30,6 +36,81 @@ from .base import DEFAULT_CLIENT_INFO, WebSecurityScannerTransport +try: + from google.api_core import client_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.websecurityscanner.v1beta.WebSecurityScanner", + "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.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WebSecurityScannerGrpcTransport(WebSecurityScannerTransport): """gRPC backend transport for WebSecurityScanner. @@ -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 @@ -262,7 +348,7 @@ def create_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_scan_config" not in self._stubs: - self._stubs["create_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["create_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/CreateScanConfig", request_serializer=web_security_scanner.CreateScanConfigRequest.serialize, response_deserializer=gcw_scan_config.ScanConfig.deserialize, @@ -289,7 +375,7 @@ def delete_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_scan_config" not in self._stubs: - self._stubs["delete_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/DeleteScanConfig", request_serializer=web_security_scanner.DeleteScanConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -315,7 +401,7 @@ def get_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_scan_config" not in self._stubs: - self._stubs["get_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["get_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/GetScanConfig", request_serializer=web_security_scanner.GetScanConfigRequest.serialize, response_deserializer=scan_config.ScanConfig.deserialize, @@ -344,7 +430,7 @@ def list_scan_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_scan_configs" not in self._stubs: - self._stubs["list_scan_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_scan_configs"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListScanConfigs", request_serializer=web_security_scanner.ListScanConfigsRequest.serialize, response_deserializer=web_security_scanner.ListScanConfigsResponse.deserialize, @@ -373,7 +459,7 @@ def update_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_scan_config" not in self._stubs: - self._stubs["update_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["update_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/UpdateScanConfig", request_serializer=web_security_scanner.UpdateScanConfigRequest.serialize, response_deserializer=gcw_scan_config.ScanConfig.deserialize, @@ -399,7 +485,7 @@ def start_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_scan_run" not in self._stubs: - self._stubs["start_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["start_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/StartScanRun", request_serializer=web_security_scanner.StartScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -425,7 +511,7 @@ def get_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_scan_run" not in self._stubs: - self._stubs["get_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["get_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/GetScanRun", request_serializer=web_security_scanner.GetScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -455,7 +541,7 @@ def list_scan_runs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_scan_runs" not in self._stubs: - self._stubs["list_scan_runs"] = self.grpc_channel.unary_unary( + self._stubs["list_scan_runs"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListScanRuns", request_serializer=web_security_scanner.ListScanRunsRequest.serialize, response_deserializer=web_security_scanner.ListScanRunsResponse.deserialize, @@ -481,7 +567,7 @@ def stop_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_scan_run" not in self._stubs: - self._stubs["stop_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["stop_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/StopScanRun", request_serializer=web_security_scanner.StopScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -510,7 +596,7 @@ def list_crawled_urls( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_crawled_urls" not in self._stubs: - self._stubs["list_crawled_urls"] = self.grpc_channel.unary_unary( + self._stubs["list_crawled_urls"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListCrawledUrls", request_serializer=web_security_scanner.ListCrawledUrlsRequest.serialize, response_deserializer=web_security_scanner.ListCrawledUrlsResponse.deserialize, @@ -536,7 +622,7 @@ def get_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_finding" not in self._stubs: - self._stubs["get_finding"] = self.grpc_channel.unary_unary( + self._stubs["get_finding"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/GetFinding", request_serializer=web_security_scanner.GetFindingRequest.serialize, response_deserializer=finding.Finding.deserialize, @@ -565,7 +651,7 @@ def list_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_findings" not in self._stubs: - self._stubs["list_findings"] = self.grpc_channel.unary_unary( + self._stubs["list_findings"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListFindings", request_serializer=web_security_scanner.ListFindingsRequest.serialize, response_deserializer=web_security_scanner.ListFindingsResponse.deserialize, @@ -594,7 +680,7 @@ def list_finding_type_stats( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_finding_type_stats" not in self._stubs: - self._stubs["list_finding_type_stats"] = self.grpc_channel.unary_unary( + self._stubs["list_finding_type_stats"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListFindingTypeStats", request_serializer=web_security_scanner.ListFindingTypeStatsRequest.serialize, response_deserializer=web_security_scanner.ListFindingTypeStatsResponse.deserialize, @@ -602,7 +688,7 @@ def list_finding_type_stats( return self._stubs["list_finding_type_stats"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc_asyncio.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc_asyncio.py index d3be3c720ebb..8b740e7dedf1 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc_asyncio.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/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.cloud.websecurityscanner_v1beta.types import scan_run, web_security_scanner from google.cloud.websecurityscanner_v1beta.types import scan_config as gcw_scan_config @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, WebSecurityScannerTransport from .grpc import WebSecurityScannerGrpcTransport +try: + from google.api_core import client_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.websecurityscanner.v1beta.WebSecurityScanner", + "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.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WebSecurityScannerGrpcAsyncIOTransport(WebSecurityScannerTransport): """gRPC AsyncIO backend transport for WebSecurityScanner. @@ -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 @@ -271,7 +356,7 @@ def create_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_scan_config" not in self._stubs: - self._stubs["create_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["create_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/CreateScanConfig", request_serializer=web_security_scanner.CreateScanConfigRequest.serialize, response_deserializer=gcw_scan_config.ScanConfig.deserialize, @@ -300,7 +385,7 @@ def delete_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_scan_config" not in self._stubs: - self._stubs["delete_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/DeleteScanConfig", request_serializer=web_security_scanner.DeleteScanConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -328,7 +413,7 @@ def get_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_scan_config" not in self._stubs: - self._stubs["get_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["get_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/GetScanConfig", request_serializer=web_security_scanner.GetScanConfigRequest.serialize, response_deserializer=scan_config.ScanConfig.deserialize, @@ -357,7 +442,7 @@ def list_scan_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_scan_configs" not in self._stubs: - self._stubs["list_scan_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_scan_configs"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListScanConfigs", request_serializer=web_security_scanner.ListScanConfigsRequest.serialize, response_deserializer=web_security_scanner.ListScanConfigsResponse.deserialize, @@ -387,7 +472,7 @@ def update_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_scan_config" not in self._stubs: - self._stubs["update_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["update_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/UpdateScanConfig", request_serializer=web_security_scanner.UpdateScanConfigRequest.serialize, response_deserializer=gcw_scan_config.ScanConfig.deserialize, @@ -415,7 +500,7 @@ def start_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_scan_run" not in self._stubs: - self._stubs["start_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["start_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/StartScanRun", request_serializer=web_security_scanner.StartScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -443,7 +528,7 @@ def get_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_scan_run" not in self._stubs: - self._stubs["get_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["get_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/GetScanRun", request_serializer=web_security_scanner.GetScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -473,7 +558,7 @@ def list_scan_runs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_scan_runs" not in self._stubs: - self._stubs["list_scan_runs"] = self.grpc_channel.unary_unary( + self._stubs["list_scan_runs"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListScanRuns", request_serializer=web_security_scanner.ListScanRunsRequest.serialize, response_deserializer=web_security_scanner.ListScanRunsResponse.deserialize, @@ -501,7 +586,7 @@ def stop_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_scan_run" not in self._stubs: - self._stubs["stop_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["stop_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/StopScanRun", request_serializer=web_security_scanner.StopScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -530,7 +615,7 @@ def list_crawled_urls( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_crawled_urls" not in self._stubs: - self._stubs["list_crawled_urls"] = self.grpc_channel.unary_unary( + self._stubs["list_crawled_urls"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListCrawledUrls", request_serializer=web_security_scanner.ListCrawledUrlsRequest.serialize, response_deserializer=web_security_scanner.ListCrawledUrlsResponse.deserialize, @@ -556,7 +641,7 @@ def get_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_finding" not in self._stubs: - self._stubs["get_finding"] = self.grpc_channel.unary_unary( + self._stubs["get_finding"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/GetFinding", request_serializer=web_security_scanner.GetFindingRequest.serialize, response_deserializer=finding.Finding.deserialize, @@ -585,7 +670,7 @@ def list_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_findings" not in self._stubs: - self._stubs["list_findings"] = self.grpc_channel.unary_unary( + self._stubs["list_findings"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListFindings", request_serializer=web_security_scanner.ListFindingsRequest.serialize, response_deserializer=web_security_scanner.ListFindingsResponse.deserialize, @@ -614,7 +699,7 @@ def list_finding_type_stats( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_finding_type_stats" not in self._stubs: - self._stubs["list_finding_type_stats"] = self.grpc_channel.unary_unary( + self._stubs["list_finding_type_stats"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListFindingTypeStats", request_serializer=web_security_scanner.ListFindingTypeStatsRequest.serialize, response_deserializer=web_security_scanner.ListFindingTypeStatsResponse.deserialize, @@ -787,7 +872,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-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/rest.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/rest.py index dd1012c8d09f..f97923c261c7 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/rest.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/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, @@ -173,8 +181,11 @@ def post_update_scan_config(self, response): def pre_create_scan_config( self, request: web_security_scanner.CreateScanConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.CreateScanConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.CreateScanConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_scan_config Override in a subclass to manipulate the request or metadata @@ -196,8 +207,11 @@ def post_create_scan_config( def pre_delete_scan_config( self, request: web_security_scanner.DeleteScanConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.DeleteScanConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.DeleteScanConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_scan_config Override in a subclass to manipulate the request or metadata @@ -208,8 +222,10 @@ def pre_delete_scan_config( def pre_get_finding( self, request: web_security_scanner.GetFindingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.GetFindingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.GetFindingRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_finding Override in a subclass to manipulate the request or metadata @@ -229,8 +245,11 @@ def post_get_finding(self, response: finding.Finding) -> finding.Finding: def pre_get_scan_config( self, request: web_security_scanner.GetScanConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.GetScanConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.GetScanConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_scan_config Override in a subclass to manipulate the request or metadata @@ -252,8 +271,10 @@ def post_get_scan_config( def pre_get_scan_run( self, request: web_security_scanner.GetScanRunRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.GetScanRunRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.GetScanRunRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_scan_run Override in a subclass to manipulate the request or metadata @@ -273,8 +294,11 @@ def post_get_scan_run(self, response: scan_run.ScanRun) -> scan_run.ScanRun: def pre_list_crawled_urls( self, request: web_security_scanner.ListCrawledUrlsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.ListCrawledUrlsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.ListCrawledUrlsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_crawled_urls Override in a subclass to manipulate the request or metadata @@ -296,8 +320,11 @@ def post_list_crawled_urls( def pre_list_findings( self, request: web_security_scanner.ListFindingsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.ListFindingsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.ListFindingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_findings Override in a subclass to manipulate the request or metadata @@ -319,9 +346,10 @@ def post_list_findings( def pre_list_finding_type_stats( self, request: web_security_scanner.ListFindingTypeStatsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - web_security_scanner.ListFindingTypeStatsRequest, Sequence[Tuple[str, str]] + web_security_scanner.ListFindingTypeStatsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_finding_type_stats @@ -344,8 +372,11 @@ def post_list_finding_type_stats( def pre_list_scan_configs( self, request: web_security_scanner.ListScanConfigsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.ListScanConfigsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.ListScanConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_scan_configs Override in a subclass to manipulate the request or metadata @@ -367,8 +398,11 @@ def post_list_scan_configs( def pre_list_scan_runs( self, request: web_security_scanner.ListScanRunsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.ListScanRunsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.ListScanRunsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_scan_runs Override in a subclass to manipulate the request or metadata @@ -390,8 +424,11 @@ def post_list_scan_runs( def pre_start_scan_run( self, request: web_security_scanner.StartScanRunRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.StartScanRunRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.StartScanRunRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for start_scan_run Override in a subclass to manipulate the request or metadata @@ -411,8 +448,10 @@ def post_start_scan_run(self, response: scan_run.ScanRun) -> scan_run.ScanRun: def pre_stop_scan_run( self, request: web_security_scanner.StopScanRunRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.StopScanRunRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.StopScanRunRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for stop_scan_run Override in a subclass to manipulate the request or metadata @@ -432,8 +471,11 @@ def post_stop_scan_run(self, response: scan_run.ScanRun) -> scan_run.ScanRun: def pre_update_scan_config( self, request: web_security_scanner.UpdateScanConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.UpdateScanConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.UpdateScanConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_scan_config Override in a subclass to manipulate the request or metadata @@ -578,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]]] = (), ) -> gcw_scan_config.ScanConfig: r"""Call the create scan config method over HTTP. @@ -588,8 +630,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gcw_scan_config.ScanConfig: @@ -601,6 +645,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseCreateScanConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_scan_config( request, metadata ) @@ -617,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.websecurityscanner_v1beta.WebSecurityScannerClient.CreateScanConfig", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "CreateScanConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._CreateScanConfig._get_response( self._host, @@ -638,7 +710,29 @@ def __call__( pb_resp = gcw_scan_config.ScanConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_scan_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcw_scan_config.ScanConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1beta.WebSecurityScannerClient.create_scan_config", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "CreateScanConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteScanConfig( @@ -676,7 +770,7 @@ 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 scan config method over HTTP. @@ -686,13 +780,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 = ( _BaseWebSecurityScannerRestTransport._BaseDeleteScanConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_scan_config( request, metadata ) @@ -705,6 +802,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1beta.WebSecurityScannerClient.DeleteScanConfig", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "DeleteScanConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._DeleteScanConfig._get_response( self._host, @@ -754,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]]] = (), ) -> finding.Finding: r"""Call the get finding method over HTTP. @@ -764,8 +888,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.finding.Finding: @@ -778,6 +904,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseGetFinding._get_http_options() ) + request, metadata = self._interceptor.pre_get_finding(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseGetFinding._get_transcoded_request( http_options, request @@ -788,6 +915,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1beta.WebSecurityScannerClient.GetFinding", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "GetFinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._GetFinding._get_response( self._host, @@ -808,7 +962,29 @@ def __call__( pb_resp = finding.Finding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_finding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = finding.Finding.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1beta.WebSecurityScannerClient.get_finding", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "GetFinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetScanConfig( @@ -846,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]]] = (), ) -> scan_config.ScanConfig: r"""Call the get scan config method over HTTP. @@ -856,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: ~.scan_config.ScanConfig: @@ -869,6 +1047,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseGetScanConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_scan_config(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseGetScanConfig._get_transcoded_request( http_options, request @@ -879,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.websecurityscanner_v1beta.WebSecurityScannerClient.GetScanConfig", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "GetScanConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._GetScanConfig._get_response( self._host, @@ -899,7 +1105,29 @@ def __call__( pb_resp = scan_config.ScanConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_scan_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_config.ScanConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1beta.WebSecurityScannerClient.get_scan_config", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "GetScanConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetScanRun( @@ -936,7 +1164,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Call the get scan run method over HTTP. @@ -946,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: ~.scan_run.ScanRun: @@ -960,6 +1190,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseGetScanRun._get_http_options() ) + request, metadata = self._interceptor.pre_get_scan_run(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseGetScanRun._get_transcoded_request( http_options, request @@ -970,6 +1201,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1beta.WebSecurityScannerClient.GetScanRun", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "GetScanRun", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._GetScanRun._get_response( self._host, @@ -990,7 +1248,29 @@ def __call__( pb_resp = scan_run.ScanRun.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_scan_run(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_run.ScanRun.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1beta.WebSecurityScannerClient.get_scan_run", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "GetScanRun", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCrawledUrls( @@ -1028,7 +1308,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListCrawledUrlsResponse: r"""Call the list crawled urls method over HTTP. @@ -1038,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: ~.web_security_scanner.ListCrawledUrlsResponse: @@ -1049,6 +1331,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListCrawledUrls._get_http_options() ) + request, metadata = self._interceptor.pre_list_crawled_urls( request, metadata ) @@ -1061,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 = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1beta.WebSecurityScannerClient.ListCrawledUrls", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "ListCrawledUrls", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._ListCrawledUrls._get_response( self._host, @@ -1081,7 +1391,31 @@ def __call__( pb_resp = web_security_scanner.ListCrawledUrlsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_crawled_urls(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListCrawledUrlsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1beta.WebSecurityScannerClient.list_crawled_urls", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "ListCrawledUrls", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListFindings( @@ -1119,7 +1453,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListFindingsResponse: r"""Call the list findings method over HTTP. @@ -1129,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: ~.web_security_scanner.ListFindingsResponse: @@ -1140,6 +1476,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListFindings._get_http_options() ) + request, metadata = self._interceptor.pre_list_findings(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseListFindings._get_transcoded_request( http_options, request @@ -1150,6 +1487,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1beta.WebSecurityScannerClient.ListFindings", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "ListFindings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._ListFindings._get_response( self._host, @@ -1170,7 +1534,31 @@ def __call__( pb_resp = web_security_scanner.ListFindingsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_findings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListFindingsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1beta.WebSecurityScannerClient.list_findings", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "ListFindings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListFindingTypeStats( @@ -1208,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]]] = (), ) -> web_security_scanner.ListFindingTypeStatsResponse: r"""Call the list finding type stats method over HTTP. @@ -1218,8 +1606,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.web_security_scanner.ListFindingTypeStatsResponse: @@ -1229,6 +1619,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListFindingTypeStats._get_http_options() ) + request, metadata = self._interceptor.pre_list_finding_type_stats( request, metadata ) @@ -1241,6 +1632,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1beta.WebSecurityScannerClient.ListFindingTypeStats", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "ListFindingTypeStats", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( WebSecurityScannerRestTransport._ListFindingTypeStats._get_response( @@ -1263,7 +1681,33 @@ def __call__( pb_resp = web_security_scanner.ListFindingTypeStatsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_finding_type_stats(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListFindingTypeStatsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1beta.WebSecurityScannerClient.list_finding_type_stats", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "ListFindingTypeStats", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListScanConfigs( @@ -1301,7 +1745,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListScanConfigsResponse: r"""Call the list scan configs method over HTTP. @@ -1311,8 +1755,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.web_security_scanner.ListScanConfigsResponse: @@ -1322,6 +1768,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListScanConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_scan_configs( request, metadata ) @@ -1334,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.websecurityscanner_v1beta.WebSecurityScannerClient.ListScanConfigs", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "ListScanConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._ListScanConfigs._get_response( self._host, @@ -1354,7 +1828,31 @@ def __call__( pb_resp = web_security_scanner.ListScanConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_scan_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListScanConfigsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1beta.WebSecurityScannerClient.list_scan_configs", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "ListScanConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListScanRuns( @@ -1392,7 +1890,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListScanRunsResponse: r"""Call the list scan runs method over HTTP. @@ -1402,8 +1900,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.web_security_scanner.ListScanRunsResponse: @@ -1413,6 +1913,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListScanRuns._get_http_options() ) + request, metadata = self._interceptor.pre_list_scan_runs(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseListScanRuns._get_transcoded_request( http_options, request @@ -1423,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.websecurityscanner_v1beta.WebSecurityScannerClient.ListScanRuns", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "ListScanRuns", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._ListScanRuns._get_response( self._host, @@ -1443,7 +1971,31 @@ def __call__( pb_resp = web_security_scanner.ListScanRunsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_scan_runs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListScanRunsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1beta.WebSecurityScannerClient.list_scan_runs", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "ListScanRuns", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StartScanRun( @@ -1482,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]]] = (), ) -> scan_run.ScanRun: r"""Call the start scan run method over HTTP. @@ -1492,8 +2044,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.scan_run.ScanRun: @@ -1506,6 +2060,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseStartScanRun._get_http_options() ) + request, metadata = self._interceptor.pre_start_scan_run(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseStartScanRun._get_transcoded_request( http_options, request @@ -1520,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.websecurityscanner_v1beta.WebSecurityScannerClient.StartScanRun", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "StartScanRun", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._StartScanRun._get_response( self._host, @@ -1541,7 +2123,29 @@ def __call__( pb_resp = scan_run.ScanRun.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_start_scan_run(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_run.ScanRun.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1beta.WebSecurityScannerClient.start_scan_run", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "StartScanRun", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StopScanRun( @@ -1580,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]]] = (), ) -> scan_run.ScanRun: r"""Call the stop scan run method over HTTP. @@ -1590,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: ~.scan_run.ScanRun: @@ -1604,6 +2210,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseStopScanRun._get_http_options() ) + request, metadata = self._interceptor.pre_stop_scan_run(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseStopScanRun._get_transcoded_request( http_options, request @@ -1618,6 +2225,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1beta.WebSecurityScannerClient.StopScanRun", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "StopScanRun", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._StopScanRun._get_response( self._host, @@ -1639,7 +2273,29 @@ def __call__( pb_resp = scan_run.ScanRun.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_stop_scan_run(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_run.ScanRun.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1beta.WebSecurityScannerClient.stop_scan_run", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "StopScanRun", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateScanConfig( @@ -1678,7 +2334,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcw_scan_config.ScanConfig: r"""Call the update scan config method over HTTP. @@ -1688,8 +2344,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gcw_scan_config.ScanConfig: @@ -1701,6 +2359,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseUpdateScanConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_scan_config( request, metadata ) @@ -1717,6 +2376,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.websecurityscanner_v1beta.WebSecurityScannerClient.UpdateScanConfig", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "UpdateScanConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._UpdateScanConfig._get_response( self._host, @@ -1738,7 +2424,29 @@ def __call__( pb_resp = gcw_scan_config.ScanConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_scan_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcw_scan_config.ScanConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.websecurityscanner_v1beta.WebSecurityScannerClient.update_scan_config", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "UpdateScanConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1.json b/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1.json index fbe13417adf8..147488567a91 100644 --- a/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1.json +++ b/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-websecurityscanner", - "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.cloud.websecurityscanner_v1.types.ScanConfig", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ScanConfig", @@ -196,7 +196,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_scan_config" @@ -269,7 +269,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_scan_config" @@ -343,7 +343,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.Finding", @@ -419,7 +419,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.Finding", @@ -496,7 +496,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ScanConfig", @@ -572,7 +572,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ScanConfig", @@ -649,7 +649,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ScanRun", @@ -725,7 +725,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ScanRun", @@ -802,7 +802,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListCrawledUrlsAsyncPager", @@ -878,7 +878,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListCrawledUrlsPager", @@ -955,7 +955,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ListFindingTypeStatsResponse", @@ -1031,7 +1031,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ListFindingTypeStatsResponse", @@ -1108,7 +1108,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListFindingsAsyncPager", @@ -1184,7 +1184,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListFindingsPager", @@ -1261,7 +1261,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListScanConfigsAsyncPager", @@ -1337,7 +1337,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListScanConfigsPager", @@ -1414,7 +1414,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListScanRunsAsyncPager", @@ -1490,7 +1490,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListScanRunsPager", @@ -1567,7 +1567,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ScanRun", @@ -1643,7 +1643,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ScanRun", @@ -1720,7 +1720,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ScanRun", @@ -1796,7 +1796,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ScanRun", @@ -1873,7 +1873,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ScanConfig", @@ -1949,7 +1949,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ScanConfig", diff --git a/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1alpha.json b/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1alpha.json index 2782c45770c8..21a75dfa6018 100644 --- a/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1alpha.json +++ b/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1alpha.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-websecurityscanner", - "version": "1.15.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.websecurityscanner_v1alpha.types.ScanConfig", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ScanConfig", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_scan_config" @@ -293,7 +293,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_scan_config" @@ -371,7 +371,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.Finding", @@ -451,7 +451,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.Finding", @@ -532,7 +532,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ScanConfig", @@ -612,7 +612,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ScanConfig", @@ -693,7 +693,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ScanRun", @@ -773,7 +773,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ScanRun", @@ -854,7 +854,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListCrawledUrlsAsyncPager", @@ -934,7 +934,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListCrawledUrlsPager", @@ -1015,7 +1015,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ListFindingTypeStatsResponse", @@ -1095,7 +1095,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ListFindingTypeStatsResponse", @@ -1180,7 +1180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListFindingsAsyncPager", @@ -1264,7 +1264,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListFindingsPager", @@ -1345,7 +1345,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListScanConfigsAsyncPager", @@ -1425,7 +1425,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListScanConfigsPager", @@ -1506,7 +1506,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListScanRunsAsyncPager", @@ -1586,7 +1586,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListScanRunsPager", @@ -1667,7 +1667,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ScanRun", @@ -1747,7 +1747,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ScanRun", @@ -1828,7 +1828,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ScanRun", @@ -1908,7 +1908,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ScanRun", @@ -1993,7 +1993,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ScanConfig", @@ -2077,7 +2077,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ScanConfig", diff --git a/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1beta.json b/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1beta.json index 50e171a75d7a..a41a6a4c4dd5 100644 --- a/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1beta.json +++ b/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1beta.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-websecurityscanner", - "version": "1.15.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.websecurityscanner_v1beta.types.ScanConfig", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ScanConfig", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_scan_config" @@ -293,7 +293,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_scan_config" @@ -371,7 +371,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.Finding", @@ -451,7 +451,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.Finding", @@ -532,7 +532,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ScanConfig", @@ -612,7 +612,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ScanConfig", @@ -693,7 +693,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ScanRun", @@ -773,7 +773,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ScanRun", @@ -854,7 +854,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListCrawledUrlsAsyncPager", @@ -934,7 +934,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListCrawledUrlsPager", @@ -1015,7 +1015,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ListFindingTypeStatsResponse", @@ -1095,7 +1095,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ListFindingTypeStatsResponse", @@ -1180,7 +1180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListFindingsAsyncPager", @@ -1264,7 +1264,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListFindingsPager", @@ -1345,7 +1345,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListScanConfigsAsyncPager", @@ -1425,7 +1425,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListScanConfigsPager", @@ -1506,7 +1506,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListScanRunsAsyncPager", @@ -1586,7 +1586,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListScanRunsPager", @@ -1667,7 +1667,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ScanRun", @@ -1747,7 +1747,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ScanRun", @@ -1828,7 +1828,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ScanRun", @@ -1908,7 +1908,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ScanRun", @@ -1993,7 +1993,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ScanConfig", @@ -2077,7 +2077,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ScanConfig", diff --git a/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1/test_web_security_scanner.py b/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1/test_web_security_scanner.py index fe85729b31f5..d07c0978e8c1 100644 --- a/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1/test_web_security_scanner.py +++ b/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1/test_web_security_scanner.py @@ -6956,6 +6956,7 @@ def test_create_scan_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_scan_config(request) @@ -7104,6 +7105,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_scan_config(request) # Establish that the response is the type that we expect. @@ -7157,6 +7159,7 @@ def test_create_scan_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 = scan_config.ScanConfig.to_json(scan_config.ScanConfig()) req.return_value.content = return_value @@ -7201,6 +7204,7 @@ def test_delete_scan_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_scan_config(request) @@ -7231,6 +7235,7 @@ def test_delete_scan_config_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_scan_config(request) # Establish that the response is the type that we expect. @@ -7267,6 +7272,7 @@ def test_delete_scan_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"} request = web_security_scanner.DeleteScanConfigRequest() metadata = [ @@ -7307,6 +7313,7 @@ def test_get_scan_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_scan_config(request) @@ -7352,6 +7359,7 @@ def test_get_scan_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_scan_config(request) # Establish that the response is the type that we expect. @@ -7405,6 +7413,7 @@ def test_get_scan_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 = scan_config.ScanConfig.to_json(scan_config.ScanConfig()) req.return_value.content = return_value @@ -7449,6 +7458,7 @@ def test_list_scan_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_scan_configs(request) @@ -7484,6 +7494,7 @@ def test_list_scan_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_scan_configs(request) # Establish that the response is the type that we expect. @@ -7524,6 +7535,7 @@ def test_list_scan_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 = web_security_scanner.ListScanConfigsResponse.to_json( web_security_scanner.ListScanConfigsResponse() ) @@ -7570,6 +7582,7 @@ def test_update_scan_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_scan_config(request) @@ -7718,6 +7731,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_scan_config(request) # Establish that the response is the type that we expect. @@ -7771,6 +7785,7 @@ def test_update_scan_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 = scan_config.ScanConfig.to_json(scan_config.ScanConfig()) req.return_value.content = return_value @@ -7815,6 +7830,7 @@ def test_start_scan_run_rest_bad_request( response_value.status_code = 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_scan_run(request) @@ -7856,6 +7872,7 @@ def test_start_scan_run_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_scan_run(request) # Establish that the response is the type that we expect. @@ -7902,6 +7919,7 @@ def test_start_scan_run_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = scan_run.ScanRun.to_json(scan_run.ScanRun()) req.return_value.content = return_value @@ -7946,6 +7964,7 @@ def test_get_scan_run_rest_bad_request( response_value.status_code = 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_scan_run(request) @@ -7987,6 +8006,7 @@ def test_get_scan_run_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_scan_run(request) # Establish that the response is the type that we expect. @@ -8033,6 +8053,7 @@ def test_get_scan_run_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = scan_run.ScanRun.to_json(scan_run.ScanRun()) req.return_value.content = return_value @@ -8077,6 +8098,7 @@ def test_list_scan_runs_rest_bad_request( response_value.status_code = 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_scan_runs(request) @@ -8112,6 +8134,7 @@ def test_list_scan_runs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_scan_runs(request) # Establish that the response is the type that we expect. @@ -8152,6 +8175,7 @@ def test_list_scan_runs_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = web_security_scanner.ListScanRunsResponse.to_json( web_security_scanner.ListScanRunsResponse() ) @@ -8198,6 +8222,7 @@ def test_stop_scan_run_rest_bad_request( response_value.status_code = 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_scan_run(request) @@ -8239,6 +8264,7 @@ def test_stop_scan_run_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_scan_run(request) # Establish that the response is the type that we expect. @@ -8285,6 +8311,7 @@ def test_stop_scan_run_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = scan_run.ScanRun.to_json(scan_run.ScanRun()) req.return_value.content = return_value @@ -8329,6 +8356,7 @@ def test_list_crawled_urls_rest_bad_request( response_value.status_code = 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_crawled_urls(request) @@ -8364,6 +8392,7 @@ def test_list_crawled_urls_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_crawled_urls(request) # Establish that the response is the type that we expect. @@ -8404,6 +8433,7 @@ def test_list_crawled_urls_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = web_security_scanner.ListCrawledUrlsResponse.to_json( web_security_scanner.ListCrawledUrlsResponse() ) @@ -8452,6 +8482,7 @@ def test_get_finding_rest_bad_request( response_value.status_code = 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_finding(request) @@ -8499,6 +8530,7 @@ def test_get_finding_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_finding(request) # Establish that the response is the type that we expect. @@ -8549,6 +8581,7 @@ def test_get_finding_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = finding.Finding.to_json(finding.Finding()) req.return_value.content = return_value @@ -8593,6 +8626,7 @@ def test_list_findings_rest_bad_request( response_value.status_code = 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_findings(request) @@ -8628,6 +8662,7 @@ def test_list_findings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_findings(request) # Establish that the response is the type that we expect. @@ -8668,6 +8703,7 @@ def test_list_findings_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = web_security_scanner.ListFindingsResponse.to_json( web_security_scanner.ListFindingsResponse() ) @@ -8714,6 +8750,7 @@ def test_list_finding_type_stats_rest_bad_request( response_value.status_code = 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_finding_type_stats(request) @@ -8749,6 +8786,7 @@ def test_list_finding_type_stats_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_finding_type_stats(request) # Establish that the response is the type that we expect. @@ -8788,6 +8826,7 @@ def test_list_finding_type_stats_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = web_security_scanner.ListFindingTypeStatsResponse.to_json( web_security_scanner.ListFindingTypeStatsResponse() ) diff --git a/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1alpha/test_web_security_scanner.py b/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1alpha/test_web_security_scanner.py index f61eef6d32c7..eca8e50dd406 100644 --- a/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1alpha/test_web_security_scanner.py +++ b/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1alpha/test_web_security_scanner.py @@ -6520,6 +6520,7 @@ def test_create_scan_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_scan_config(request) @@ -6574,6 +6575,7 @@ def test_create_scan_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_scan_config(**mock_args) @@ -6706,6 +6708,7 @@ def test_delete_scan_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_scan_config(request) @@ -6749,6 +6752,7 @@ def test_delete_scan_config_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_scan_config(**mock_args) @@ -6879,6 +6883,7 @@ def test_get_scan_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_scan_config(request) @@ -6924,6 +6929,7 @@ def test_get_scan_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_scan_config(**mock_args) @@ -7063,6 +7069,7 @@ def test_list_scan_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_scan_configs(request) @@ -7116,6 +7123,7 @@ def test_list_scan_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_scan_configs(**mock_args) @@ -7311,6 +7319,7 @@ def test_update_scan_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_scan_config(request) @@ -7367,6 +7376,7 @@ def test_update_scan_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_scan_config(**mock_args) @@ -7500,6 +7510,7 @@ def test_start_scan_run_rest_required_fields( response_value._content = json_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_scan_run(request) @@ -7545,6 +7556,7 @@ def test_start_scan_run_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_scan_run(**mock_args) @@ -7675,6 +7687,7 @@ def test_get_scan_run_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_scan_run(request) @@ -7722,6 +7735,7 @@ def test_get_scan_run_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_scan_run(**mock_args) @@ -7860,6 +7874,7 @@ def test_list_scan_runs_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_scan_runs(request) @@ -7913,6 +7928,7 @@ def test_list_scan_runs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_scan_runs(**mock_args) @@ -8108,6 +8124,7 @@ def test_stop_scan_run_rest_required_fields( response_value._content = json_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_scan_run(request) @@ -8155,6 +8172,7 @@ def test_stop_scan_run_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_scan_run(**mock_args) @@ -8295,6 +8313,7 @@ def test_list_crawled_urls_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_crawled_urls(request) @@ -8350,6 +8369,7 @@ def test_list_crawled_urls_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_crawled_urls(**mock_args) @@ -8546,6 +8566,7 @@ def test_get_finding_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_finding(request) @@ -8593,6 +8614,7 @@ def test_get_finding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_finding(**mock_args) @@ -8739,6 +8761,7 @@ def test_list_findings_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_findings(request) @@ -8807,6 +8830,7 @@ def test_list_findings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_findings(**mock_args) @@ -9011,6 +9035,7 @@ def test_list_finding_type_stats_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_finding_type_stats(request) @@ -9060,6 +9085,7 @@ def test_list_finding_type_stats_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_finding_type_stats(**mock_args) @@ -9924,6 +9950,7 @@ def test_create_scan_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_scan_config(request) @@ -10070,6 +10097,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_scan_config(request) # Establish that the response is the type that we expect. @@ -10118,6 +10146,7 @@ def test_create_scan_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 = gcw_scan_config.ScanConfig.to_json(gcw_scan_config.ScanConfig()) req.return_value.content = return_value @@ -10162,6 +10191,7 @@ def test_delete_scan_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_scan_config(request) @@ -10192,6 +10222,7 @@ def test_delete_scan_config_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_scan_config(request) # Establish that the response is the type that we expect. @@ -10228,6 +10259,7 @@ def test_delete_scan_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"} request = web_security_scanner.DeleteScanConfigRequest() metadata = [ @@ -10268,6 +10300,7 @@ def test_get_scan_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_scan_config(request) @@ -10309,6 +10342,7 @@ def test_get_scan_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_scan_config(request) # Establish that the response is the type that we expect. @@ -10357,6 +10391,7 @@ def test_get_scan_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 = scan_config.ScanConfig.to_json(scan_config.ScanConfig()) req.return_value.content = return_value @@ -10401,6 +10436,7 @@ def test_list_scan_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_scan_configs(request) @@ -10436,6 +10472,7 @@ def test_list_scan_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_scan_configs(request) # Establish that the response is the type that we expect. @@ -10476,6 +10513,7 @@ def test_list_scan_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 = web_security_scanner.ListScanConfigsResponse.to_json( web_security_scanner.ListScanConfigsResponse() ) @@ -10522,6 +10560,7 @@ def test_update_scan_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_scan_config(request) @@ -10668,6 +10707,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_scan_config(request) # Establish that the response is the type that we expect. @@ -10716,6 +10756,7 @@ def test_update_scan_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 = gcw_scan_config.ScanConfig.to_json(gcw_scan_config.ScanConfig()) req.return_value.content = return_value @@ -10760,6 +10801,7 @@ def test_start_scan_run_rest_bad_request( response_value.status_code = 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_scan_run(request) @@ -10801,6 +10843,7 @@ def test_start_scan_run_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_scan_run(request) # Establish that the response is the type that we expect. @@ -10847,6 +10890,7 @@ def test_start_scan_run_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = scan_run.ScanRun.to_json(scan_run.ScanRun()) req.return_value.content = return_value @@ -10891,6 +10935,7 @@ def test_get_scan_run_rest_bad_request( response_value.status_code = 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_scan_run(request) @@ -10932,6 +10977,7 @@ def test_get_scan_run_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_scan_run(request) # Establish that the response is the type that we expect. @@ -10978,6 +11024,7 @@ def test_get_scan_run_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = scan_run.ScanRun.to_json(scan_run.ScanRun()) req.return_value.content = return_value @@ -11022,6 +11069,7 @@ def test_list_scan_runs_rest_bad_request( response_value.status_code = 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_scan_runs(request) @@ -11057,6 +11105,7 @@ def test_list_scan_runs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_scan_runs(request) # Establish that the response is the type that we expect. @@ -11097,6 +11146,7 @@ def test_list_scan_runs_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = web_security_scanner.ListScanRunsResponse.to_json( web_security_scanner.ListScanRunsResponse() ) @@ -11143,6 +11193,7 @@ def test_stop_scan_run_rest_bad_request( response_value.status_code = 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_scan_run(request) @@ -11184,6 +11235,7 @@ def test_stop_scan_run_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_scan_run(request) # Establish that the response is the type that we expect. @@ -11230,6 +11282,7 @@ def test_stop_scan_run_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = scan_run.ScanRun.to_json(scan_run.ScanRun()) req.return_value.content = return_value @@ -11274,6 +11327,7 @@ def test_list_crawled_urls_rest_bad_request( response_value.status_code = 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_crawled_urls(request) @@ -11309,6 +11363,7 @@ def test_list_crawled_urls_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_crawled_urls(request) # Establish that the response is the type that we expect. @@ -11349,6 +11404,7 @@ def test_list_crawled_urls_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = web_security_scanner.ListCrawledUrlsResponse.to_json( web_security_scanner.ListCrawledUrlsResponse() ) @@ -11397,6 +11453,7 @@ def test_get_finding_rest_bad_request( response_value.status_code = 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_finding(request) @@ -11443,6 +11500,7 @@ def test_get_finding_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_finding(request) # Establish that the response is the type that we expect. @@ -11492,6 +11550,7 @@ def test_get_finding_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = finding.Finding.to_json(finding.Finding()) req.return_value.content = return_value @@ -11536,6 +11595,7 @@ def test_list_findings_rest_bad_request( response_value.status_code = 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_findings(request) @@ -11571,6 +11631,7 @@ def test_list_findings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_findings(request) # Establish that the response is the type that we expect. @@ -11611,6 +11672,7 @@ def test_list_findings_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = web_security_scanner.ListFindingsResponse.to_json( web_security_scanner.ListFindingsResponse() ) @@ -11657,6 +11719,7 @@ def test_list_finding_type_stats_rest_bad_request( response_value.status_code = 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_finding_type_stats(request) @@ -11692,6 +11755,7 @@ def test_list_finding_type_stats_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_finding_type_stats(request) # Establish that the response is the type that we expect. @@ -11731,6 +11795,7 @@ def test_list_finding_type_stats_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = web_security_scanner.ListFindingTypeStatsResponse.to_json( web_security_scanner.ListFindingTypeStatsResponse() ) diff --git a/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1beta/test_web_security_scanner.py b/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1beta/test_web_security_scanner.py index 7e41bc395da4..e731e5ab7299 100644 --- a/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1beta/test_web_security_scanner.py +++ b/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1beta/test_web_security_scanner.py @@ -6568,6 +6568,7 @@ def test_create_scan_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_scan_config(request) @@ -6622,6 +6623,7 @@ def test_create_scan_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_scan_config(**mock_args) @@ -6754,6 +6756,7 @@ def test_delete_scan_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_scan_config(request) @@ -6797,6 +6800,7 @@ def test_delete_scan_config_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_scan_config(**mock_args) @@ -6927,6 +6931,7 @@ def test_get_scan_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_scan_config(request) @@ -6972,6 +6977,7 @@ def test_get_scan_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_scan_config(**mock_args) @@ -7111,6 +7117,7 @@ def test_list_scan_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_scan_configs(request) @@ -7164,6 +7171,7 @@ def test_list_scan_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_scan_configs(**mock_args) @@ -7359,6 +7367,7 @@ def test_update_scan_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_scan_config(request) @@ -7415,6 +7424,7 @@ def test_update_scan_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_scan_config(**mock_args) @@ -7548,6 +7558,7 @@ def test_start_scan_run_rest_required_fields( response_value._content = json_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_scan_run(request) @@ -7593,6 +7604,7 @@ def test_start_scan_run_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_scan_run(**mock_args) @@ -7723,6 +7735,7 @@ def test_get_scan_run_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_scan_run(request) @@ -7770,6 +7783,7 @@ def test_get_scan_run_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_scan_run(**mock_args) @@ -7908,6 +7922,7 @@ def test_list_scan_runs_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_scan_runs(request) @@ -7961,6 +7976,7 @@ def test_list_scan_runs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_scan_runs(**mock_args) @@ -8156,6 +8172,7 @@ def test_stop_scan_run_rest_required_fields( response_value._content = json_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_scan_run(request) @@ -8203,6 +8220,7 @@ def test_stop_scan_run_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_scan_run(**mock_args) @@ -8343,6 +8361,7 @@ def test_list_crawled_urls_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_crawled_urls(request) @@ -8398,6 +8417,7 @@ def test_list_crawled_urls_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_crawled_urls(**mock_args) @@ -8594,6 +8614,7 @@ def test_get_finding_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_finding(request) @@ -8641,6 +8662,7 @@ def test_get_finding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_finding(**mock_args) @@ -8787,6 +8809,7 @@ def test_list_findings_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_findings(request) @@ -8855,6 +8878,7 @@ def test_list_findings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_findings(**mock_args) @@ -9059,6 +9083,7 @@ def test_list_finding_type_stats_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_finding_type_stats(request) @@ -9108,6 +9133,7 @@ def test_list_finding_type_stats_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_finding_type_stats(**mock_args) @@ -9978,6 +10004,7 @@ def test_create_scan_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_scan_config(request) @@ -10134,6 +10161,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_scan_config(request) # Establish that the response is the type that we expect. @@ -10187,6 +10215,7 @@ def test_create_scan_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 = gcw_scan_config.ScanConfig.to_json(gcw_scan_config.ScanConfig()) req.return_value.content = return_value @@ -10231,6 +10260,7 @@ def test_delete_scan_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_scan_config(request) @@ -10261,6 +10291,7 @@ def test_delete_scan_config_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_scan_config(request) # Establish that the response is the type that we expect. @@ -10297,6 +10328,7 @@ def test_delete_scan_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"} request = web_security_scanner.DeleteScanConfigRequest() metadata = [ @@ -10337,6 +10369,7 @@ def test_get_scan_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_scan_config(request) @@ -10380,6 +10413,7 @@ def test_get_scan_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_scan_config(request) # Establish that the response is the type that we expect. @@ -10433,6 +10467,7 @@ def test_get_scan_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 = scan_config.ScanConfig.to_json(scan_config.ScanConfig()) req.return_value.content = return_value @@ -10477,6 +10512,7 @@ def test_list_scan_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_scan_configs(request) @@ -10512,6 +10548,7 @@ def test_list_scan_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_scan_configs(request) # Establish that the response is the type that we expect. @@ -10552,6 +10589,7 @@ def test_list_scan_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 = web_security_scanner.ListScanConfigsResponse.to_json( web_security_scanner.ListScanConfigsResponse() ) @@ -10598,6 +10636,7 @@ def test_update_scan_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_scan_config(request) @@ -10754,6 +10793,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_scan_config(request) # Establish that the response is the type that we expect. @@ -10807,6 +10847,7 @@ def test_update_scan_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 = gcw_scan_config.ScanConfig.to_json(gcw_scan_config.ScanConfig()) req.return_value.content = return_value @@ -10851,6 +10892,7 @@ def test_start_scan_run_rest_bad_request( response_value.status_code = 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_scan_run(request) @@ -10892,6 +10934,7 @@ def test_start_scan_run_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_scan_run(request) # Establish that the response is the type that we expect. @@ -10938,6 +10981,7 @@ def test_start_scan_run_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = scan_run.ScanRun.to_json(scan_run.ScanRun()) req.return_value.content = return_value @@ -10982,6 +11026,7 @@ def test_get_scan_run_rest_bad_request( response_value.status_code = 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_scan_run(request) @@ -11023,6 +11068,7 @@ def test_get_scan_run_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_scan_run(request) # Establish that the response is the type that we expect. @@ -11069,6 +11115,7 @@ def test_get_scan_run_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = scan_run.ScanRun.to_json(scan_run.ScanRun()) req.return_value.content = return_value @@ -11113,6 +11160,7 @@ def test_list_scan_runs_rest_bad_request( response_value.status_code = 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_scan_runs(request) @@ -11148,6 +11196,7 @@ def test_list_scan_runs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_scan_runs(request) # Establish that the response is the type that we expect. @@ -11188,6 +11237,7 @@ def test_list_scan_runs_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = web_security_scanner.ListScanRunsResponse.to_json( web_security_scanner.ListScanRunsResponse() ) @@ -11234,6 +11284,7 @@ def test_stop_scan_run_rest_bad_request( response_value.status_code = 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_scan_run(request) @@ -11275,6 +11326,7 @@ def test_stop_scan_run_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_scan_run(request) # Establish that the response is the type that we expect. @@ -11321,6 +11373,7 @@ def test_stop_scan_run_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = scan_run.ScanRun.to_json(scan_run.ScanRun()) req.return_value.content = return_value @@ -11365,6 +11418,7 @@ def test_list_crawled_urls_rest_bad_request( response_value.status_code = 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_crawled_urls(request) @@ -11400,6 +11454,7 @@ def test_list_crawled_urls_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_crawled_urls(request) # Establish that the response is the type that we expect. @@ -11440,6 +11495,7 @@ def test_list_crawled_urls_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = web_security_scanner.ListCrawledUrlsResponse.to_json( web_security_scanner.ListCrawledUrlsResponse() ) @@ -11488,6 +11544,7 @@ def test_get_finding_rest_bad_request( response_value.status_code = 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_finding(request) @@ -11534,6 +11591,7 @@ def test_get_finding_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_finding(request) # Establish that the response is the type that we expect. @@ -11583,6 +11641,7 @@ def test_get_finding_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = finding.Finding.to_json(finding.Finding()) req.return_value.content = return_value @@ -11627,6 +11686,7 @@ def test_list_findings_rest_bad_request( response_value.status_code = 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_findings(request) @@ -11662,6 +11722,7 @@ def test_list_findings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_findings(request) # Establish that the response is the type that we expect. @@ -11702,6 +11763,7 @@ def test_list_findings_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = web_security_scanner.ListFindingsResponse.to_json( web_security_scanner.ListFindingsResponse() ) @@ -11748,6 +11810,7 @@ def test_list_finding_type_stats_rest_bad_request( response_value.status_code = 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_finding_type_stats(request) @@ -11783,6 +11846,7 @@ def test_list_finding_type_stats_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_finding_type_stats(request) # Establish that the response is the type that we expect. @@ -11822,6 +11886,7 @@ def test_list_finding_type_stats_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = web_security_scanner.ListFindingTypeStatsResponse.to_json( web_security_scanner.ListFindingTypeStatsResponse() ) diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions/gapic_version.py b/packages/google-cloud-workflows/google/cloud/workflows/executions/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions/gapic_version.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions/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-workflows/google/cloud/workflows/executions_v1/gapic_version.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/gapic_version.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_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-workflows/google/cloud/workflows/executions_v1/services/executions/async_client.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/async_client.py index ece3c3598599..a54a789d2975 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/async_client.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/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, @@ -52,6 +53,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ExecutionsTransport from .transports.grpc_asyncio import ExecutionsGrpcAsyncIOTransport +try: + from google.api_core import client_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 ExecutionsAsyncClient: """Executions is used to start and manage running instances of @@ -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.workflows.executions_v1.ExecutionsAsyncClient`.", + extra={ + "serviceName": "google.cloud.workflows.executions.v1.Executions", + "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.workflows.executions.v1.Executions", + "credentialsType": None, + }, + ) + async def list_executions( self, request: Optional[Union[executions.ListExecutionsRequest, dict]] = None, @@ -262,7 +294,7 @@ async def list_executions( 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.ListExecutionsAsyncPager: r"""Returns a list of executions which belong to the workflow with the given name. The method returns @@ -312,8 +344,10 @@ async def sample_list_executions(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workflows.executions_v1.services.executions.pagers.ListExecutionsAsyncPager: @@ -390,7 +424,7 @@ async def create_execution( execution: Optional[executions.Execution] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> executions.Execution: r"""Creates a new execution using the latest revision of the given workflow. @@ -445,8 +479,10 @@ async def sample_create_execution(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workflows.executions_v1.types.Execution: @@ -509,7 +545,7 @@ async def get_execution( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> executions.Execution: r"""Returns an execution of the given name. @@ -556,8 +592,10 @@ async def sample_get_execution(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workflows.executions_v1.types.Execution: @@ -618,7 +656,7 @@ async def cancel_execution( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> executions.Execution: r"""Cancels an execution of the given name. @@ -665,8 +703,10 @@ async def sample_cancel_execution(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workflows.executions_v1.types.Execution: diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/client.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/client.py index 66a2899d88cc..e97f953c9e22 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/client.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/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 duration_pb2 # type: ignore from google.protobuf import timestamp_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.workflows.executions_v1.ExecutionsClient`.", + extra={ + "serviceName": "google.cloud.workflows.executions.v1.Executions", + "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.workflows.executions.v1.Executions", + "credentialsType": None, + }, + ) + def list_executions( self, request: Optional[Union[executions.ListExecutionsRequest, dict]] = None, @@ -672,7 +709,7 @@ def list_executions( 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.ListExecutionsPager: r"""Returns a list of executions which belong to the workflow with the given name. The method returns @@ -722,8 +759,10 @@ def sample_list_executions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workflows.executions_v1.services.executions.pagers.ListExecutionsPager: @@ -797,7 +836,7 @@ def create_execution( execution: Optional[executions.Execution] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> executions.Execution: r"""Creates a new execution using the latest revision of the given workflow. @@ -852,8 +891,10 @@ def sample_create_execution(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workflows.executions_v1.types.Execution: @@ -913,7 +954,7 @@ def get_execution( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> executions.Execution: r"""Returns an execution of the given name. @@ -960,8 +1001,10 @@ def sample_get_execution(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workflows.executions_v1.types.Execution: @@ -1019,7 +1062,7 @@ def cancel_execution( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> executions.Execution: r"""Cancels an execution of the given name. @@ -1066,8 +1109,10 @@ def sample_cancel_execution(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workflows.executions_v1.types.Execution: diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/pagers.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/pagers.py index 523a88da088b..ebd469bfee57 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/pagers.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/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 = executions.ListExecutionsRequest(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 = executions.ListExecutionsRequest(request) diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/transports/grpc.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/transports/grpc.py index 4589058a30c5..f71cf7bad475 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/transports/grpc.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/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.cloud.workflows.executions_v1.types import executions from .base import DEFAULT_CLIENT_INFO, ExecutionsTransport +try: + from google.api_core import client_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.workflows.executions.v1.Executions", + "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.workflows.executions.v1.Executions", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ExecutionsGrpcTransport(ExecutionsTransport): """gRPC backend transport for Executions. @@ -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 @@ -260,7 +346,7 @@ def list_executions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_executions" not in self._stubs: - self._stubs["list_executions"] = self.grpc_channel.unary_unary( + self._stubs["list_executions"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1.Executions/ListExecutions", request_serializer=executions.ListExecutionsRequest.serialize, response_deserializer=executions.ListExecutionsResponse.deserialize, @@ -287,7 +373,7 @@ def create_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_execution" not in self._stubs: - self._stubs["create_execution"] = self.grpc_channel.unary_unary( + self._stubs["create_execution"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1.Executions/CreateExecution", request_serializer=executions.CreateExecutionRequest.serialize, response_deserializer=executions.Execution.deserialize, @@ -313,7 +399,7 @@ def get_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_execution" not in self._stubs: - self._stubs["get_execution"] = self.grpc_channel.unary_unary( + self._stubs["get_execution"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1.Executions/GetExecution", request_serializer=executions.GetExecutionRequest.serialize, response_deserializer=executions.Execution.deserialize, @@ -339,7 +425,7 @@ def cancel_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_execution" not in self._stubs: - self._stubs["cancel_execution"] = self.grpc_channel.unary_unary( + self._stubs["cancel_execution"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1.Executions/CancelExecution", request_serializer=executions.CancelExecutionRequest.serialize, response_deserializer=executions.Execution.deserialize, @@ -347,7 +433,7 @@ def cancel_execution( return self._stubs["cancel_execution"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/transports/grpc_asyncio.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/transports/grpc_asyncio.py index 5cda3e22528f..4a44d93b3f12 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/transports/grpc_asyncio.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/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.cloud.workflows.executions_v1.types import executions from .base import DEFAULT_CLIENT_INFO, ExecutionsTransport from .grpc import ExecutionsGrpcTransport +try: + from google.api_core import client_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.workflows.executions.v1.Executions", + "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.workflows.executions.v1.Executions", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ExecutionsGrpcAsyncIOTransport(ExecutionsTransport): """gRPC AsyncIO backend transport for Executions. @@ -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 @@ -268,7 +353,7 @@ def list_executions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_executions" not in self._stubs: - self._stubs["list_executions"] = self.grpc_channel.unary_unary( + self._stubs["list_executions"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1.Executions/ListExecutions", request_serializer=executions.ListExecutionsRequest.serialize, response_deserializer=executions.ListExecutionsResponse.deserialize, @@ -295,7 +380,7 @@ def create_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_execution" not in self._stubs: - self._stubs["create_execution"] = self.grpc_channel.unary_unary( + self._stubs["create_execution"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1.Executions/CreateExecution", request_serializer=executions.CreateExecutionRequest.serialize, response_deserializer=executions.Execution.deserialize, @@ -321,7 +406,7 @@ def get_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_execution" not in self._stubs: - self._stubs["get_execution"] = self.grpc_channel.unary_unary( + self._stubs["get_execution"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1.Executions/GetExecution", request_serializer=executions.GetExecutionRequest.serialize, response_deserializer=executions.Execution.deserialize, @@ -347,7 +432,7 @@ def cancel_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_execution" not in self._stubs: - self._stubs["cancel_execution"] = self.grpc_channel.unary_unary( + self._stubs["cancel_execution"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1.Executions/CancelExecution", request_serializer=executions.CancelExecutionRequest.serialize, response_deserializer=executions.Execution.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: diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/gapic_version.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/gapic_version.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/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-workflows/google/cloud/workflows/executions_v1beta/services/executions/async_client.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/async_client.py index 67c7af47b23f..8d2cf92100ea 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/async_client.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/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, ExecutionsTransport from .transports.grpc_asyncio import ExecutionsGrpcAsyncIOTransport +try: + from google.api_core import client_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 ExecutionsAsyncClient: """Executions is used to start and manage running instances of @@ -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.workflows.executions_v1beta.ExecutionsAsyncClient`.", + extra={ + "serviceName": "google.cloud.workflows.executions.v1beta.Executions", + "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.workflows.executions.v1beta.Executions", + "credentialsType": None, + }, + ) + async def list_executions( self, request: Optional[Union[executions.ListExecutionsRequest, dict]] = None, @@ -262,7 +294,7 @@ async def list_executions( 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.ListExecutionsAsyncPager: r"""Returns a list of executions which belong to the workflow with the given name. The method returns @@ -314,8 +346,10 @@ async def sample_list_executions(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workflows.executions_v1beta.services.executions.pagers.ListExecutionsAsyncPager: @@ -392,7 +426,7 @@ async def create_execution( execution: Optional[executions.Execution] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> executions.Execution: r"""Creates a new execution using the latest revision of the given workflow. @@ -447,8 +481,10 @@ async def sample_create_execution(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workflows.executions_v1beta.types.Execution: @@ -511,7 +547,7 @@ async def get_execution( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> executions.Execution: r"""Returns an execution of the given name. @@ -558,8 +594,10 @@ async def sample_get_execution(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workflows.executions_v1beta.types.Execution: @@ -620,7 +658,7 @@ async def cancel_execution( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> executions.Execution: r"""Cancels an execution of the given name. @@ -667,8 +705,10 @@ async def sample_cancel_execution(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workflows.executions_v1beta.types.Execution: diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/client.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/client.py index b760e063c950..2e4ff661809c 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/client.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/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.cloud.workflows.executions_v1beta.services.executions import pagers @@ -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.workflows.executions_v1beta.ExecutionsClient`.", + extra={ + "serviceName": "google.cloud.workflows.executions.v1beta.Executions", + "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.workflows.executions.v1beta.Executions", + "credentialsType": None, + }, + ) + def list_executions( self, request: Optional[Union[executions.ListExecutionsRequest, dict]] = None, @@ -672,7 +709,7 @@ def list_executions( 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.ListExecutionsPager: r"""Returns a list of executions which belong to the workflow with the given name. The method returns @@ -724,8 +761,10 @@ def sample_list_executions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workflows.executions_v1beta.services.executions.pagers.ListExecutionsPager: @@ -799,7 +838,7 @@ def create_execution( execution: Optional[executions.Execution] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> executions.Execution: r"""Creates a new execution using the latest revision of the given workflow. @@ -854,8 +893,10 @@ def sample_create_execution(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workflows.executions_v1beta.types.Execution: @@ -915,7 +956,7 @@ def get_execution( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> executions.Execution: r"""Returns an execution of the given name. @@ -962,8 +1003,10 @@ def sample_get_execution(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workflows.executions_v1beta.types.Execution: @@ -1021,7 +1064,7 @@ def cancel_execution( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> executions.Execution: r"""Cancels an execution of the given name. @@ -1068,8 +1111,10 @@ def sample_cancel_execution(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workflows.executions_v1beta.types.Execution: diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/pagers.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/pagers.py index 6ab8021fa8a2..19dec411d569 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/pagers.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/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 = executions.ListExecutionsRequest(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 = executions.ListExecutionsRequest(request) diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/transports/grpc.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/transports/grpc.py index bc053be2ff61..e3343974ce55 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/transports/grpc.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/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.cloud.workflows.executions_v1beta.types import executions from .base import DEFAULT_CLIENT_INFO, ExecutionsTransport +try: + from google.api_core import client_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.workflows.executions.v1beta.Executions", + "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.workflows.executions.v1beta.Executions", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ExecutionsGrpcTransport(ExecutionsTransport): """gRPC backend transport for Executions. @@ -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 @@ -261,7 +347,7 @@ def list_executions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_executions" not in self._stubs: - self._stubs["list_executions"] = self.grpc_channel.unary_unary( + self._stubs["list_executions"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1beta.Executions/ListExecutions", request_serializer=executions.ListExecutionsRequest.serialize, response_deserializer=executions.ListExecutionsResponse.deserialize, @@ -288,7 +374,7 @@ def create_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_execution" not in self._stubs: - self._stubs["create_execution"] = self.grpc_channel.unary_unary( + self._stubs["create_execution"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1beta.Executions/CreateExecution", request_serializer=executions.CreateExecutionRequest.serialize, response_deserializer=executions.Execution.deserialize, @@ -314,7 +400,7 @@ def get_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_execution" not in self._stubs: - self._stubs["get_execution"] = self.grpc_channel.unary_unary( + self._stubs["get_execution"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1beta.Executions/GetExecution", request_serializer=executions.GetExecutionRequest.serialize, response_deserializer=executions.Execution.deserialize, @@ -340,7 +426,7 @@ def cancel_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_execution" not in self._stubs: - self._stubs["cancel_execution"] = self.grpc_channel.unary_unary( + self._stubs["cancel_execution"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1beta.Executions/CancelExecution", request_serializer=executions.CancelExecutionRequest.serialize, response_deserializer=executions.Execution.deserialize, @@ -348,7 +434,7 @@ def cancel_execution( return self._stubs["cancel_execution"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/transports/grpc_asyncio.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/transports/grpc_asyncio.py index 13d57d0ad17f..af19660c074b 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/transports/grpc_asyncio.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/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.cloud.workflows.executions_v1beta.types import executions from .base import DEFAULT_CLIENT_INFO, ExecutionsTransport from .grpc import ExecutionsGrpcTransport +try: + from google.api_core import client_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.workflows.executions.v1beta.Executions", + "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.workflows.executions.v1beta.Executions", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ExecutionsGrpcAsyncIOTransport(ExecutionsTransport): """gRPC AsyncIO backend transport for Executions. @@ -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 @@ -269,7 +354,7 @@ def list_executions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_executions" not in self._stubs: - self._stubs["list_executions"] = self.grpc_channel.unary_unary( + self._stubs["list_executions"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1beta.Executions/ListExecutions", request_serializer=executions.ListExecutionsRequest.serialize, response_deserializer=executions.ListExecutionsResponse.deserialize, @@ -296,7 +381,7 @@ def create_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_execution" not in self._stubs: - self._stubs["create_execution"] = self.grpc_channel.unary_unary( + self._stubs["create_execution"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1beta.Executions/CreateExecution", request_serializer=executions.CreateExecutionRequest.serialize, response_deserializer=executions.Execution.deserialize, @@ -322,7 +407,7 @@ def get_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_execution" not in self._stubs: - self._stubs["get_execution"] = self.grpc_channel.unary_unary( + self._stubs["get_execution"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1beta.Executions/GetExecution", request_serializer=executions.GetExecutionRequest.serialize, response_deserializer=executions.Execution.deserialize, @@ -348,7 +433,7 @@ def cancel_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_execution" not in self._stubs: - self._stubs["cancel_execution"] = self.grpc_channel.unary_unary( + self._stubs["cancel_execution"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1beta.Executions/CancelExecution", request_serializer=executions.CancelExecutionRequest.serialize, response_deserializer=executions.Execution.deserialize, @@ -386,7 +471,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-workflows/google/cloud/workflows/gapic_version.py b/packages/google-cloud-workflows/google/cloud/workflows/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/gapic_version.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/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-workflows/google/cloud/workflows_v1/gapic_version.py b/packages/google-cloud-workflows/google/cloud/workflows_v1/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1/gapic_version.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_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-workflows/google/cloud/workflows_v1/services/workflows/async_client.py b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/async_client.py index 73e7f1be93f7..6d163e6c1b20 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/async_client.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/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, WorkflowsTransport from .transports.grpc_asyncio import WorkflowsGrpcAsyncIOTransport +try: + from google.api_core import client_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 WorkflowsAsyncClient: """Workflows is used to deploy and execute workflow programs. @@ -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.workflows_v1.WorkflowsAsyncClient`.", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "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.workflows.v1.Workflows", + "credentialsType": None, + }, + ) + async def list_workflows( self, request: Optional[Union[workflows.ListWorkflowsRequest, dict]] = None, @@ -268,7 +300,7 @@ async def list_workflows( 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.ListWorkflowsAsyncPager: r"""Lists workflows in a given project and location. The default order is not specified. @@ -317,8 +349,10 @@ async def sample_list_workflows(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workflows_v1.services.workflows.pagers.ListWorkflowsAsyncPager: @@ -394,7 +428,7 @@ async def get_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workflows.Workflow: r"""Gets details of a single workflow. @@ -441,8 +475,10 @@ async def sample_get_workflow(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workflows_v1.types.Workflow: @@ -505,7 +541,7 @@ async def create_workflow( workflow_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 workflow. If a workflow with the specified name already exists in the specified project and location, the long @@ -584,8 +620,10 @@ async def sample_create_workflow(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -661,7 +699,7 @@ async def delete_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_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 workflow with the specified name. This method also cancels and deletes all running @@ -713,8 +751,10 @@ async def sample_delete_workflow(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -794,7 +834,7 @@ async def update_workflow( 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 an existing workflow. Running this method has no impact on already running @@ -857,8 +897,10 @@ async def sample_update_workflow(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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 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 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. @@ -1055,8 +1101,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 """ @@ -1093,7 +1141,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. @@ -1104,8 +1152,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. @@ -1146,7 +1196,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. @@ -1157,8 +1207,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-workflows/google/cloud/workflows_v1/services/workflows/client.py b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/client.py index 28ee4a70547d..3456ac7e278d 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/client.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/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 @@ -611,6 +621,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( @@ -673,6 +687,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.workflows_v1.WorkflowsClient`.", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "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.workflows.v1.Workflows", + "credentialsType": None, + }, + ) + def list_workflows( self, request: Optional[Union[workflows.ListWorkflowsRequest, dict]] = None, @@ -680,7 +717,7 @@ def list_workflows( 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.ListWorkflowsPager: r"""Lists workflows in a given project and location. The default order is not specified. @@ -729,8 +766,10 @@ def sample_list_workflows(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workflows_v1.services.workflows.pagers.ListWorkflowsPager: @@ -803,7 +842,7 @@ def get_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workflows.Workflow: r"""Gets details of a single workflow. @@ -850,8 +889,10 @@ def sample_get_workflow(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workflows_v1.types.Workflow: @@ -911,7 +952,7 @@ def create_workflow( workflow_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 workflow. If a workflow with the specified name already exists in the specified project and location, the long @@ -990,8 +1031,10 @@ def sample_create_workflow(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1064,7 +1107,7 @@ def delete_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_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 workflow with the specified name. This method also cancels and deletes all running @@ -1116,8 +1159,10 @@ def sample_delete_workflow(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1194,7 +1239,7 @@ def update_workflow( 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 an existing workflow. Running this method has no impact on already running @@ -1257,8 +1302,10 @@ def sample_update_workflow(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1343,7 +1390,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. @@ -1354,8 +1401,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. @@ -1396,7 +1445,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. @@ -1407,8 +1456,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. @@ -1449,7 +1500,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. @@ -1465,8 +1516,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 """ @@ -1503,7 +1556,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. @@ -1514,8 +1567,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. @@ -1556,7 +1611,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. @@ -1567,8 +1622,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-workflows/google/cloud/workflows_v1/services/workflows/pagers.py b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/pagers.py index 2fa3c7ad226b..d5d5b49bd7e8 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/pagers.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/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 = workflows.ListWorkflowsRequest(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 = workflows.ListWorkflowsRequest(request) diff --git a/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/transports/grpc.py b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/transports/grpc.py index b0ee002b6167..9caa13723fa1 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/transports/grpc.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/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.workflows_v1.types import workflows from .base import DEFAULT_CLIENT_INFO, WorkflowsTransport +try: + from google.api_core import client_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.workflows.v1.Workflows", + "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.workflows.v1.Workflows", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WorkflowsGrpcTransport(WorkflowsTransport): """gRPC backend transport for Workflows. @@ -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_workflows( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workflows" not in self._stubs: - self._stubs["list_workflows"] = self.grpc_channel.unary_unary( + self._stubs["list_workflows"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1.Workflows/ListWorkflows", request_serializer=workflows.ListWorkflowsRequest.serialize, response_deserializer=workflows.ListWorkflowsResponse.deserialize, @@ -299,7 +387,7 @@ def get_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workflow" not in self._stubs: - self._stubs["get_workflow"] = self.grpc_channel.unary_unary( + self._stubs["get_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1.Workflows/GetWorkflow", request_serializer=workflows.GetWorkflowRequest.serialize, response_deserializer=workflows.Workflow.deserialize, @@ -328,7 +416,7 @@ def create_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workflow" not in self._stubs: - self._stubs["create_workflow"] = self.grpc_channel.unary_unary( + self._stubs["create_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1.Workflows/CreateWorkflow", request_serializer=workflows.CreateWorkflowRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -356,7 +444,7 @@ def delete_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workflow" not in self._stubs: - self._stubs["delete_workflow"] = self.grpc_channel.unary_unary( + self._stubs["delete_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1.Workflows/DeleteWorkflow", request_serializer=workflows.DeleteWorkflowRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -387,7 +475,7 @@ def update_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workflow" not in self._stubs: - self._stubs["update_workflow"] = self.grpc_channel.unary_unary( + self._stubs["update_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1.Workflows/UpdateWorkflow", request_serializer=workflows.UpdateWorkflowRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -395,7 +483,7 @@ def update_workflow( return self._stubs["update_workflow"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -407,7 +495,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, @@ -424,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, @@ -443,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, @@ -462,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, @@ -479,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-workflows/google/cloud/workflows_v1/services/workflows/transports/grpc_asyncio.py b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/transports/grpc_asyncio.py index 44a12240a3eb..db7184556fa4 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/transports/grpc_asyncio.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/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.workflows_v1.types import workflows from .base import DEFAULT_CLIENT_INFO, WorkflowsTransport from .grpc import WorkflowsGrpcTransport +try: + from google.api_core import client_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.workflows.v1.Workflows", + "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.workflows.v1.Workflows", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WorkflowsGrpcAsyncIOTransport(WorkflowsTransport): """gRPC AsyncIO backend transport for Workflows. @@ -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_workflows( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workflows" not in self._stubs: - self._stubs["list_workflows"] = self.grpc_channel.unary_unary( + self._stubs["list_workflows"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1.Workflows/ListWorkflows", request_serializer=workflows.ListWorkflowsRequest.serialize, response_deserializer=workflows.ListWorkflowsResponse.deserialize, @@ -311,7 +396,7 @@ def get_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workflow" not in self._stubs: - self._stubs["get_workflow"] = self.grpc_channel.unary_unary( + self._stubs["get_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1.Workflows/GetWorkflow", request_serializer=workflows.GetWorkflowRequest.serialize, response_deserializer=workflows.Workflow.deserialize, @@ -342,7 +427,7 @@ def create_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workflow" not in self._stubs: - self._stubs["create_workflow"] = self.grpc_channel.unary_unary( + self._stubs["create_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1.Workflows/CreateWorkflow", request_serializer=workflows.CreateWorkflowRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -372,7 +457,7 @@ def delete_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workflow" not in self._stubs: - self._stubs["delete_workflow"] = self.grpc_channel.unary_unary( + self._stubs["delete_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1.Workflows/DeleteWorkflow", request_serializer=workflows.DeleteWorkflowRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -405,7 +490,7 @@ def update_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workflow" not in self._stubs: - self._stubs["update_workflow"] = self.grpc_channel.unary_unary( + self._stubs["update_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1.Workflows/UpdateWorkflow", request_serializer=workflows.UpdateWorkflowRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -473,7 +558,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: @@ -489,7 +574,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, @@ -506,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, @@ -525,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, @@ -544,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, @@ -561,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-workflows/google/cloud/workflows_v1/services/workflows/transports/rest.py b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/transports/rest.py index 2df29537d5b2..edd59bc56b8e 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/transports/rest.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/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, @@ -111,8 +119,10 @@ def post_update_workflow(self, response): def pre_create_workflow( self, request: workflows.CreateWorkflowRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workflows.CreateWorkflowRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workflows.CreateWorkflowRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_workflow Override in a subclass to manipulate the request or metadata @@ -134,8 +144,10 @@ def post_create_workflow( def pre_delete_workflow( self, request: workflows.DeleteWorkflowRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workflows.DeleteWorkflowRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workflows.DeleteWorkflowRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_workflow Override in a subclass to manipulate the request or metadata @@ -155,8 +167,10 @@ def post_delete_workflow( return response def pre_get_workflow( - self, request: workflows.GetWorkflowRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[workflows.GetWorkflowRequest, Sequence[Tuple[str, str]]]: + self, + request: workflows.GetWorkflowRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[workflows.GetWorkflowRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_workflow Override in a subclass to manipulate the request or metadata @@ -176,8 +190,8 @@ def post_get_workflow(self, response: workflows.Workflow) -> workflows.Workflow: def pre_list_workflows( self, request: workflows.ListWorkflowsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workflows.ListWorkflowsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[workflows.ListWorkflowsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_workflows Override in a subclass to manipulate the request or metadata @@ -199,8 +213,10 @@ def post_list_workflows( def pre_update_workflow( self, request: workflows.UpdateWorkflowRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workflows.UpdateWorkflowRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workflows.UpdateWorkflowRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_workflow Override in a subclass to manipulate the request or metadata @@ -222,8 +238,10 @@ def post_update_workflow( 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 @@ -245,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 @@ -268,8 +288,10 @@ def post_list_locations( 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 @@ -289,8 +311,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 @@ -312,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 @@ -503,7 +529,7 @@ 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 workflow method over HTTP. @@ -515,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: ~.operations_pb2.Operation: @@ -529,6 +557,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseCreateWorkflow._get_http_options() ) + request, metadata = self._interceptor.pre_create_workflow(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseCreateWorkflow._get_transcoded_request( @@ -549,6 +578,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workflows_v1.WorkflowsClient.CreateWorkflow", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "CreateWorkflow", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._CreateWorkflow._get_response( self._host, @@ -568,7 +624,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_workflow(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workflows_v1.WorkflowsClient.create_workflow", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "CreateWorkflow", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteWorkflow( @@ -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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete workflow 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: ~.operations_pb2.Operation: @@ -631,6 +711,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseDeleteWorkflow._get_http_options() ) + request, metadata = self._interceptor.pre_delete_workflow(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseDeleteWorkflow._get_transcoded_request( @@ -645,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.workflows_v1.WorkflowsClient.DeleteWorkflow", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "DeleteWorkflow", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._DeleteWorkflow._get_response( self._host, @@ -663,7 +771,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_workflow(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workflows_v1.WorkflowsClient.delete_workflow", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "DeleteWorkflow", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetWorkflow(_BaseWorkflowsRestTransport._BaseGetWorkflow, WorkflowsRestStub): @@ -698,7 +828,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workflows.Workflow: r"""Call the get workflow method over HTTP. @@ -710,8 +840,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.workflows.Workflow: @@ -723,6 +855,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseGetWorkflow._get_http_options() ) + request, metadata = self._interceptor.pre_get_workflow(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseGetWorkflow._get_transcoded_request( @@ -737,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.workflows_v1.WorkflowsClient.GetWorkflow", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "GetWorkflow", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._GetWorkflow._get_response( self._host, @@ -757,7 +917,29 @@ def __call__( pb_resp = workflows.Workflow.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_workflow(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workflows.Workflow.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workflows_v1.WorkflowsClient.get_workflow", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "GetWorkflow", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListWorkflows( @@ -794,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]]] = (), ) -> workflows.ListWorkflowsResponse: r"""Call the list workflows method over HTTP. @@ -806,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: ~.workflows.ListWorkflowsResponse: @@ -820,6 +1004,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseListWorkflows._get_http_options() ) + request, metadata = self._interceptor.pre_list_workflows(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseListWorkflows._get_transcoded_request( @@ -834,6 +1019,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workflows_v1.WorkflowsClient.ListWorkflows", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "ListWorkflows", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._ListWorkflows._get_response( self._host, @@ -854,7 +1066,29 @@ def __call__( pb_resp = workflows.ListWorkflowsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_workflows(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workflows.ListWorkflowsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workflows_v1.WorkflowsClient.list_workflows", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "ListWorkflows", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateWorkflow( @@ -892,7 +1126,7 @@ 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 workflow method over HTTP. @@ -904,8 +1138,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -918,6 +1154,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseUpdateWorkflow._get_http_options() ) + request, metadata = self._interceptor.pre_update_workflow(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseUpdateWorkflow._get_transcoded_request( @@ -938,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workflows_v1.WorkflowsClient.UpdateWorkflow", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "UpdateWorkflow", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._UpdateWorkflow._get_response( self._host, @@ -957,7 +1221,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_workflow(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workflows_v1.WorkflowsClient.update_workflow", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "UpdateWorkflow", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1036,7 +1322,7 @@ 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. @@ -1046,8 +1332,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1056,6 +1344,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseGetLocation._get_transcoded_request( @@ -1070,6 +1359,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workflows_v1.WorkflowsClient.GetLocation", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._GetLocation._get_response( self._host, @@ -1089,6 +1405,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.workflows_v1.WorkflowsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1129,7 +1466,7 @@ 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. @@ -1139,8 +1476,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1149,6 +1488,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseListLocations._get_transcoded_request( @@ -1163,6 +1503,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workflows_v1.WorkflowsClient.ListLocations", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._ListLocations._get_response( self._host, @@ -1182,6 +1549,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.workflows_v1.WorkflowsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1222,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]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -1232,13 +1620,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 = ( _BaseWorkflowsRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1253,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workflows_v1.WorkflowsClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._DeleteOperation._get_response( self._host, @@ -1308,7 +1726,7 @@ 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. @@ -1318,8 +1736,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -1328,6 +1748,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseGetOperation._get_transcoded_request( @@ -1342,6 +1763,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workflows_v1.WorkflowsClient.GetOperation", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._GetOperation._get_response( self._host, @@ -1361,6 +1809,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.workflows_v1.WorkflowsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1401,7 +1870,7 @@ 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. @@ -1411,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1421,6 +1892,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseListOperations._get_transcoded_request( @@ -1435,6 +1907,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workflows_v1.WorkflowsClient.ListOperations", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._ListOperations._get_response( self._host, @@ -1454,6 +1953,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.workflows_v1.WorkflowsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/gapic_version.py b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/gapic_version.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/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-workflows/google/cloud/workflows_v1beta/services/workflows/async_client.py b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/async_client.py index 91aab3e657c1..c1703f4925a3 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/async_client.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/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, WorkflowsTransport from .transports.grpc_asyncio import WorkflowsGrpcAsyncIOTransport +try: + from google.api_core import client_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 WorkflowsAsyncClient: """Workflows is used to deploy and execute workflow programs. @@ -257,6 +267,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.workflows_v1beta.WorkflowsAsyncClient`.", + extra={ + "serviceName": "google.cloud.workflows.v1beta.Workflows", + "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.workflows.v1beta.Workflows", + "credentialsType": None, + }, + ) + async def list_workflows( self, request: Optional[Union[workflows.ListWorkflowsRequest, dict]] = None, @@ -264,7 +296,7 @@ async def list_workflows( 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.ListWorkflowsAsyncPager: r"""Lists Workflows in a given project and location. The default order is not specified. @@ -313,8 +345,10 @@ async def sample_list_workflows(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workflows_v1beta.services.workflows.pagers.ListWorkflowsAsyncPager: @@ -390,7 +424,7 @@ async def get_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workflows.Workflow: r"""Gets details of a single Workflow. @@ -436,8 +470,10 @@ async def sample_get_workflow(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workflows_v1beta.types.Workflow: @@ -500,7 +536,7 @@ async def create_workflow( workflow_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 workflow. If a workflow with the specified name already exists in the specified project and location, the long @@ -579,8 +615,10 @@ async def sample_create_workflow(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_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 workflow with the specified name. This method also cancels and deletes all running @@ -708,8 +746,10 @@ async def sample_delete_workflow(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -789,7 +829,7 @@ async def update_workflow( 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 an existing workflow. Running this method has no impact on already running @@ -852,8 +892,10 @@ async def sample_update_workflow(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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-workflows/google/cloud/workflows_v1beta/services/workflows/client.py b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/client.py index 8bbe5daaa8c7..52dbc7aecb88 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/client.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/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 @@ -585,6 +595,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.workflows_v1beta.WorkflowsClient`.", + extra={ + "serviceName": "google.cloud.workflows.v1beta.Workflows", + "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.workflows.v1beta.Workflows", + "credentialsType": None, + }, + ) + def list_workflows( self, request: Optional[Union[workflows.ListWorkflowsRequest, dict]] = None, @@ -654,7 +691,7 @@ def list_workflows( 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.ListWorkflowsPager: r"""Lists Workflows in a given project and location. The default order is not specified. @@ -703,8 +740,10 @@ def sample_list_workflows(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workflows_v1beta.services.workflows.pagers.ListWorkflowsPager: @@ -777,7 +816,7 @@ def get_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workflows.Workflow: r"""Gets details of a single Workflow. @@ -823,8 +862,10 @@ def sample_get_workflow(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workflows_v1beta.types.Workflow: @@ -884,7 +925,7 @@ def create_workflow( workflow_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 workflow. If a workflow with the specified name already exists in the specified project and location, the long @@ -963,8 +1004,10 @@ def sample_create_workflow(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1037,7 +1080,7 @@ def delete_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_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 workflow with the specified name. This method also cancels and deletes all running @@ -1089,8 +1132,10 @@ def sample_delete_workflow(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -1167,7 +1212,7 @@ def update_workflow( 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 an existing workflow. Running this method has no impact on already running @@ -1230,8 +1275,10 @@ def sample_update_workflow(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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-workflows/google/cloud/workflows_v1beta/services/workflows/pagers.py b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/pagers.py index c64b64bf418e..fa9cca58678b 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/pagers.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/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 = workflows.ListWorkflowsRequest(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 = workflows.ListWorkflowsRequest(request) diff --git a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/transports/grpc.py b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/transports/grpc.py index a55080caad4b..09294f765536 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/transports/grpc.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/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.workflows_v1beta.types import workflows from .base import DEFAULT_CLIENT_INFO, WorkflowsTransport +try: + from google.api_core import client_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.workflows.v1beta.Workflows", + "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.workflows.v1beta.Workflows", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WorkflowsGrpcTransport(WorkflowsTransport): """gRPC backend transport for Workflows. @@ -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 @@ -247,7 +333,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 list_workflows( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workflows" not in self._stubs: - self._stubs["list_workflows"] = self.grpc_channel.unary_unary( + self._stubs["list_workflows"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1beta.Workflows/ListWorkflows", request_serializer=workflows.ListWorkflowsRequest.serialize, response_deserializer=workflows.ListWorkflowsResponse.deserialize, @@ -298,7 +386,7 @@ def get_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workflow" not in self._stubs: - self._stubs["get_workflow"] = self.grpc_channel.unary_unary( + self._stubs["get_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1beta.Workflows/GetWorkflow", request_serializer=workflows.GetWorkflowRequest.serialize, response_deserializer=workflows.Workflow.deserialize, @@ -327,7 +415,7 @@ def create_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workflow" not in self._stubs: - self._stubs["create_workflow"] = self.grpc_channel.unary_unary( + self._stubs["create_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1beta.Workflows/CreateWorkflow", request_serializer=workflows.CreateWorkflowRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -355,7 +443,7 @@ def delete_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workflow" not in self._stubs: - self._stubs["delete_workflow"] = self.grpc_channel.unary_unary( + self._stubs["delete_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1beta.Workflows/DeleteWorkflow", request_serializer=workflows.DeleteWorkflowRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -386,7 +474,7 @@ def update_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workflow" not in self._stubs: - self._stubs["update_workflow"] = self.grpc_channel.unary_unary( + self._stubs["update_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1beta.Workflows/UpdateWorkflow", request_serializer=workflows.UpdateWorkflowRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -394,7 +482,7 @@ def update_workflow( return self._stubs["update_workflow"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/transports/grpc_asyncio.py b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/transports/grpc_asyncio.py index 7c057305b3ef..2e7074c5917d 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/transports/grpc_asyncio.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/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.workflows_v1beta.types import workflows from .base import DEFAULT_CLIENT_INFO, WorkflowsTransport from .grpc import WorkflowsGrpcTransport +try: + from google.api_core import client_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.workflows.v1beta.Workflows", + "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.workflows.v1beta.Workflows", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WorkflowsGrpcAsyncIOTransport(WorkflowsTransport): """gRPC AsyncIO backend transport for Workflows. @@ -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 @@ -256,7 +341,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_workflows( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workflows" not in self._stubs: - self._stubs["list_workflows"] = self.grpc_channel.unary_unary( + self._stubs["list_workflows"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1beta.Workflows/ListWorkflows", request_serializer=workflows.ListWorkflowsRequest.serialize, response_deserializer=workflows.ListWorkflowsResponse.deserialize, @@ -310,7 +395,7 @@ def get_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workflow" not in self._stubs: - self._stubs["get_workflow"] = self.grpc_channel.unary_unary( + self._stubs["get_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1beta.Workflows/GetWorkflow", request_serializer=workflows.GetWorkflowRequest.serialize, response_deserializer=workflows.Workflow.deserialize, @@ -341,7 +426,7 @@ def create_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workflow" not in self._stubs: - self._stubs["create_workflow"] = self.grpc_channel.unary_unary( + self._stubs["create_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1beta.Workflows/CreateWorkflow", request_serializer=workflows.CreateWorkflowRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -371,7 +456,7 @@ def delete_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workflow" not in self._stubs: - self._stubs["delete_workflow"] = self.grpc_channel.unary_unary( + self._stubs["delete_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1beta.Workflows/DeleteWorkflow", request_serializer=workflows.DeleteWorkflowRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -404,7 +489,7 @@ def update_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workflow" not in self._stubs: - self._stubs["update_workflow"] = self.grpc_channel.unary_unary( + self._stubs["update_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1beta.Workflows/UpdateWorkflow", request_serializer=workflows.UpdateWorkflowRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -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: diff --git a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/transports/rest.py b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/transports/rest.py index fa45293023b2..e69848b1336a 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/transports/rest.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/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, @@ -110,8 +118,10 @@ def post_update_workflow(self, response): def pre_create_workflow( self, request: workflows.CreateWorkflowRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workflows.CreateWorkflowRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workflows.CreateWorkflowRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_workflow Override in a subclass to manipulate the request or metadata @@ -133,8 +143,10 @@ def post_create_workflow( def pre_delete_workflow( self, request: workflows.DeleteWorkflowRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workflows.DeleteWorkflowRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workflows.DeleteWorkflowRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_workflow Override in a subclass to manipulate the request or metadata @@ -154,8 +166,10 @@ def post_delete_workflow( return response def pre_get_workflow( - self, request: workflows.GetWorkflowRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[workflows.GetWorkflowRequest, Sequence[Tuple[str, str]]]: + self, + request: workflows.GetWorkflowRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[workflows.GetWorkflowRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_workflow Override in a subclass to manipulate the request or metadata @@ -175,8 +189,8 @@ def post_get_workflow(self, response: workflows.Workflow) -> workflows.Workflow: def pre_list_workflows( self, request: workflows.ListWorkflowsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workflows.ListWorkflowsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[workflows.ListWorkflowsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_workflows Override in a subclass to manipulate the request or metadata @@ -198,8 +212,10 @@ def post_list_workflows( def pre_update_workflow( self, request: workflows.UpdateWorkflowRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workflows.UpdateWorkflowRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workflows.UpdateWorkflowRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_workflow Override in a subclass to manipulate the request or metadata @@ -389,7 +405,7 @@ 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 workflow method over HTTP. @@ -401,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: ~.operations_pb2.Operation: @@ -415,6 +433,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseCreateWorkflow._get_http_options() ) + request, metadata = self._interceptor.pre_create_workflow(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseCreateWorkflow._get_transcoded_request( @@ -435,6 +454,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workflows_v1beta.WorkflowsClient.CreateWorkflow", + extra={ + "serviceName": "google.cloud.workflows.v1beta.Workflows", + "rpcName": "CreateWorkflow", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._CreateWorkflow._get_response( self._host, @@ -454,7 +500,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_workflow(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workflows_v1beta.WorkflowsClient.create_workflow", + extra={ + "serviceName": "google.cloud.workflows.v1beta.Workflows", + "rpcName": "CreateWorkflow", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteWorkflow( @@ -491,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete workflow method over HTTP. @@ -503,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: ~.operations_pb2.Operation: @@ -517,6 +587,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseDeleteWorkflow._get_http_options() ) + request, metadata = self._interceptor.pre_delete_workflow(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseDeleteWorkflow._get_transcoded_request( @@ -531,6 +602,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workflows_v1beta.WorkflowsClient.DeleteWorkflow", + extra={ + "serviceName": "google.cloud.workflows.v1beta.Workflows", + "rpcName": "DeleteWorkflow", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._DeleteWorkflow._get_response( self._host, @@ -549,7 +647,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_workflow(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workflows_v1beta.WorkflowsClient.delete_workflow", + extra={ + "serviceName": "google.cloud.workflows.v1beta.Workflows", + "rpcName": "DeleteWorkflow", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetWorkflow(_BaseWorkflowsRestTransport._BaseGetWorkflow, WorkflowsRestStub): @@ -584,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]]] = (), ) -> workflows.Workflow: r"""Call the get workflow method over HTTP. @@ -596,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: ~.workflows.Workflow: @@ -609,6 +731,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseGetWorkflow._get_http_options() ) + request, metadata = self._interceptor.pre_get_workflow(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseGetWorkflow._get_transcoded_request( @@ -623,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.workflows_v1beta.WorkflowsClient.GetWorkflow", + extra={ + "serviceName": "google.cloud.workflows.v1beta.Workflows", + "rpcName": "GetWorkflow", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._GetWorkflow._get_response( self._host, @@ -643,7 +793,29 @@ def __call__( pb_resp = workflows.Workflow.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_workflow(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workflows.Workflow.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workflows_v1beta.WorkflowsClient.get_workflow", + extra={ + "serviceName": "google.cloud.workflows.v1beta.Workflows", + "rpcName": "GetWorkflow", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListWorkflows( @@ -680,7 +852,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workflows.ListWorkflowsResponse: r"""Call the list workflows method over HTTP. @@ -692,8 +864,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.workflows.ListWorkflowsResponse: @@ -706,6 +880,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseListWorkflows._get_http_options() ) + request, metadata = self._interceptor.pre_list_workflows(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseListWorkflows._get_transcoded_request( @@ -720,6 +895,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workflows_v1beta.WorkflowsClient.ListWorkflows", + extra={ + "serviceName": "google.cloud.workflows.v1beta.Workflows", + "rpcName": "ListWorkflows", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._ListWorkflows._get_response( self._host, @@ -740,7 +942,29 @@ def __call__( pb_resp = workflows.ListWorkflowsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_workflows(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workflows.ListWorkflowsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workflows_v1beta.WorkflowsClient.list_workflows", + extra={ + "serviceName": "google.cloud.workflows.v1beta.Workflows", + "rpcName": "ListWorkflows", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateWorkflow( @@ -778,7 +1002,7 @@ 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 workflow method over HTTP. @@ -790,8 +1014,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -804,6 +1030,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseUpdateWorkflow._get_http_options() ) + request, metadata = self._interceptor.pre_update_workflow(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseUpdateWorkflow._get_transcoded_request( @@ -824,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workflows_v1beta.WorkflowsClient.UpdateWorkflow", + extra={ + "serviceName": "google.cloud.workflows.v1beta.Workflows", + "rpcName": "UpdateWorkflow", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._UpdateWorkflow._get_response( self._host, @@ -843,7 +1097,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_workflow(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workflows_v1beta.WorkflowsClient.update_workflow", + extra={ + "serviceName": "google.cloud.workflows.v1beta.Workflows", + "rpcName": "UpdateWorkflow", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.executions.v1.json b/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.executions.v1.json index 2ee63c867fef..fba2ed08eb7a 100644 --- a/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.executions.v1.json +++ b/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.executions.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-workflows-executions", - "version": "1.15.1" + "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.cloud.workflows.executions_v1.types.Execution", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1.types.Execution", @@ -212,7 +212,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1.types.Execution", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1.types.Execution", @@ -377,7 +377,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1.types.Execution", @@ -457,7 +457,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1.types.Execution", @@ -538,7 +538,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1.services.executions.pagers.ListExecutionsAsyncPager", @@ -618,7 +618,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1.services.executions.pagers.ListExecutionsPager", diff --git a/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.executions.v1beta.json b/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.executions.v1beta.json index 42b4bc366890..6f534b55fa27 100644 --- a/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.executions.v1beta.json +++ b/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.executions.v1beta.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-workflows-executions", - "version": "1.15.1" + "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.cloud.workflows.executions_v1beta.types.Execution", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1beta.types.Execution", @@ -212,7 +212,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1beta.types.Execution", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1beta.types.Execution", @@ -377,7 +377,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1beta.types.Execution", @@ -457,7 +457,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1beta.types.Execution", @@ -538,7 +538,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1beta.services.executions.pagers.ListExecutionsAsyncPager", @@ -618,7 +618,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1beta.services.executions.pagers.ListExecutionsPager", diff --git a/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.v1.json b/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.v1.json index a1f43fefe508..d0498f290f1f 100644 --- a/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.v1.json +++ b/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-workflows", - "version": "1.15.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", @@ -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.workflows_v1.types.Workflow", @@ -465,7 +465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows_v1.types.Workflow", @@ -546,7 +546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows_v1.services.workflows.pagers.ListWorkflowsAsyncPager", @@ -626,7 +626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows_v1.services.workflows.pagers.ListWorkflowsPager", @@ -711,7 +711,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -795,7 +795,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-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.v1beta.json b/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.v1beta.json index a8ed8d67b8de..1e4a9ce7a54e 100644 --- a/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.v1beta.json +++ b/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.v1beta.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-workflows", - "version": "1.15.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", @@ -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.workflows_v1beta.types.Workflow", @@ -465,7 +465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows_v1beta.types.Workflow", @@ -546,7 +546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows_v1beta.services.workflows.pagers.ListWorkflowsAsyncPager", @@ -626,7 +626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows_v1beta.services.workflows.pagers.ListWorkflowsPager", @@ -711,7 +711,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -795,7 +795,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-workflows/tests/unit/gapic/workflows_v1/test_workflows.py b/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1/test_workflows.py index f56443c5a54f..c613c1671b54 100644 --- a/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1/test_workflows.py +++ b/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1/test_workflows.py @@ -3022,6 +3022,7 @@ def test_list_workflows_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_workflows(request) @@ -3077,6 +3078,7 @@ def test_list_workflows_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workflows(**mock_args) @@ -3268,6 +3270,7 @@ def test_get_workflow_rest_required_fields(request_type=workflows.GetWorkflowReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_workflow(request) @@ -3315,6 +3318,7 @@ def test_get_workflow_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workflow(**mock_args) @@ -3456,6 +3460,7 @@ def test_create_workflow_rest_required_fields( response_value._content = json_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_workflow(request) @@ -3516,6 +3521,7 @@ def test_create_workflow_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workflow(**mock_args) @@ -3649,6 +3655,7 @@ def test_delete_workflow_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_workflow(request) @@ -3694,6 +3701,7 @@ def test_delete_workflow_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workflow(**mock_args) @@ -3823,6 +3831,7 @@ def test_update_workflow_rest_required_fields( response_value._content = json_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_workflow(request) @@ -3869,6 +3878,7 @@ def test_update_workflow_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workflow(**mock_args) @@ -4286,6 +4296,7 @@ def test_list_workflows_rest_bad_request(request_type=workflows.ListWorkflowsReq response_value.status_code = 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_workflows(request) @@ -4322,6 +4333,7 @@ def test_list_workflows_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_workflows(request) # Establish that the response is the type that we expect. @@ -4359,6 +4371,7 @@ def test_list_workflows_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = workflows.ListWorkflowsResponse.to_json( workflows.ListWorkflowsResponse() ) @@ -4403,6 +4416,7 @@ def test_get_workflow_rest_bad_request(request_type=workflows.GetWorkflowRequest response_value.status_code = 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_workflow(request) @@ -4445,6 +4459,7 @@ def test_get_workflow_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_workflow(request) # Establish that the response is the type that we expect. @@ -4487,6 +4502,7 @@ def test_get_workflow_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = workflows.Workflow.to_json(workflows.Workflow()) req.return_value.content = return_value @@ -4529,6 +4545,7 @@ def test_create_workflow_rest_bad_request(request_type=workflows.CreateWorkflowR response_value.status_code = 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_workflow(request) @@ -4642,6 +4659,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_workflow(request) # Establish that the response is the type that we expect. @@ -4681,6 +4699,7 @@ def test_create_workflow_rest_interceptors(null_interceptor): req.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 @@ -4723,6 +4742,7 @@ def test_delete_workflow_rest_bad_request(request_type=workflows.DeleteWorkflowR response_value.status_code = 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_workflow(request) @@ -4753,6 +4773,7 @@ def test_delete_workflow_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_workflow(request) # Establish that the response is the type that we expect. @@ -4792,6 +4813,7 @@ def test_delete_workflow_rest_interceptors(null_interceptor): req.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 @@ -4836,6 +4858,7 @@ def test_update_workflow_rest_bad_request(request_type=workflows.UpdateWorkflowR response_value.status_code = 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_workflow(request) @@ -4951,6 +4974,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_workflow(request) # Establish that the response is the type that we expect. @@ -4990,6 +5014,7 @@ def test_update_workflow_rest_interceptors(null_interceptor): req.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 @@ -5034,6 +5059,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) @@ -5064,6 +5090,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) @@ -5092,6 +5119,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) @@ -5122,6 +5150,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) @@ -5152,6 +5181,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) @@ -5182,6 +5212,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) @@ -5212,6 +5243,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) @@ -5242,6 +5274,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) @@ -5272,6 +5305,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) @@ -5302,6 +5336,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-workflows/tests/unit/gapic/workflows_v1beta/test_workflows.py b/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1beta/test_workflows.py index 21824db1272f..e327a5532b35 100644 --- a/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1beta/test_workflows.py +++ b/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1beta/test_workflows.py @@ -3011,6 +3011,7 @@ def test_list_workflows_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_workflows(request) @@ -3066,6 +3067,7 @@ def test_list_workflows_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workflows(**mock_args) @@ -3256,6 +3258,7 @@ def test_get_workflow_rest_required_fields(request_type=workflows.GetWorkflowReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_workflow(request) @@ -3303,6 +3306,7 @@ def test_get_workflow_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workflow(**mock_args) @@ -3445,6 +3449,7 @@ def test_create_workflow_rest_required_fields( response_value._content = json_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_workflow(request) @@ -3505,6 +3510,7 @@ def test_create_workflow_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workflow(**mock_args) @@ -3639,6 +3645,7 @@ def test_delete_workflow_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_workflow(request) @@ -3684,6 +3691,7 @@ def test_delete_workflow_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workflow(**mock_args) @@ -3814,6 +3822,7 @@ def test_update_workflow_rest_required_fields( response_value._content = json_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_workflow(request) @@ -3860,6 +3869,7 @@ def test_update_workflow_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workflow(**mock_args) @@ -4275,6 +4285,7 @@ def test_list_workflows_rest_bad_request(request_type=workflows.ListWorkflowsReq response_value.status_code = 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_workflows(request) @@ -4311,6 +4322,7 @@ def test_list_workflows_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_workflows(request) # Establish that the response is the type that we expect. @@ -4348,6 +4360,7 @@ def test_list_workflows_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = workflows.ListWorkflowsResponse.to_json( workflows.ListWorkflowsResponse() ) @@ -4392,6 +4405,7 @@ def test_get_workflow_rest_bad_request(request_type=workflows.GetWorkflowRequest response_value.status_code = 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_workflow(request) @@ -4432,6 +4446,7 @@ def test_get_workflow_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_workflow(request) # Establish that the response is the type that we expect. @@ -4472,6 +4487,7 @@ def test_get_workflow_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = workflows.Workflow.to_json(workflows.Workflow()) req.return_value.content = return_value @@ -4514,6 +4530,7 @@ def test_create_workflow_rest_bad_request(request_type=workflows.CreateWorkflowR response_value.status_code = 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_workflow(request) @@ -4623,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.create_workflow(request) # Establish that the response is the type that we expect. @@ -4662,6 +4680,7 @@ def test_create_workflow_rest_interceptors(null_interceptor): req.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 @@ -4704,6 +4723,7 @@ def test_delete_workflow_rest_bad_request(request_type=workflows.DeleteWorkflowR response_value.status_code = 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_workflow(request) @@ -4734,6 +4754,7 @@ def test_delete_workflow_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_workflow(request) # Establish that the response is the type that we expect. @@ -4773,6 +4794,7 @@ def test_delete_workflow_rest_interceptors(null_interceptor): req.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 @@ -4817,6 +4839,7 @@ def test_update_workflow_rest_bad_request(request_type=workflows.UpdateWorkflowR response_value.status_code = 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_workflow(request) @@ -4928,6 +4951,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_workflow(request) # Establish that the response is the type that we expect. @@ -4967,6 +4991,7 @@ def test_update_workflow_rest_interceptors(null_interceptor): req.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-workstations/google/cloud/workstations/gapic_version.py b/packages/google-cloud-workstations/google/cloud/workstations/gapic_version.py index 2b5369e53dc7..558c8aab67c5 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations/gapic_version.py +++ b/packages/google-cloud-workstations/google/cloud/workstations/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.5.10" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-workstations/google/cloud/workstations_v1/gapic_version.py b/packages/google-cloud-workstations/google/cloud/workstations_v1/gapic_version.py index 2b5369e53dc7..558c8aab67c5 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1/gapic_version.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.5.10" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/async_client.py b/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/async_client.py index 9ed87dd4b5ed..ea6f05edbcf7 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/async_client.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/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, WorkstationsTransport from .transports.grpc_asyncio import WorkstationsGrpcAsyncIOTransport +try: + from google.api_core import client_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 WorkstationsAsyncClient: """Service for interacting with Cloud Workstations.""" @@ -269,6 +279,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.workstations_v1.WorkstationsAsyncClient`.", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "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.workstations.v1.Workstations", + "credentialsType": None, + }, + ) + async def get_workstation_cluster( self, request: Optional[ @@ -278,7 +310,7 @@ async def get_workstation_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]]] = (), ) -> workstations.WorkstationCluster: r"""Returns the requested workstation cluster. @@ -322,8 +354,10 @@ async def sample_get_workstation_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.workstations_v1.types.WorkstationCluster: @@ -389,7 +423,7 @@ async def list_workstation_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.ListWorkstationClustersAsyncPager: r"""Returns all workstation clusters in the specified location. @@ -433,8 +467,10 @@ async def sample_list_workstation_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.workstations_v1.services.workstations.pagers.ListWorkstationClustersAsyncPager: @@ -513,7 +549,7 @@ async def create_workstation_cluster( workstation_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 workstation cluster. @@ -574,8 +610,10 @@ async def sample_create_workstation_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: @@ -660,7 +698,7 @@ async def update_workstation_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 an existing workstation cluster. @@ -715,8 +753,10 @@ async def sample_update_workstation_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: @@ -798,7 +838,7 @@ async def delete_workstation_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 the specified workstation cluster. @@ -846,8 +886,10 @@ async def sample_delete_workstation_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 get_workstation_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.WorkstationConfig: r"""Returns the requested workstation configuration. @@ -967,8 +1009,10 @@ async def sample_get_workstation_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.cloud.workstations_v1.types.WorkstationConfig: @@ -1042,7 +1086,7 @@ async def list_workstation_configs( 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.ListWorkstationConfigsAsyncPager: r"""Returns all workstation configurations in the specified cluster. @@ -1086,8 +1130,10 @@ async def sample_list_workstation_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.workstations_v1.services.workstations.pagers.ListWorkstationConfigsAsyncPager: @@ -1164,7 +1210,7 @@ async def list_usable_workstation_configs( 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.ListUsableWorkstationConfigsAsyncPager: r"""Returns all workstation configurations in the specified cluster on which the caller has the @@ -1209,8 +1255,10 @@ async def sample_list_usable_workstation_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.workstations_v1.services.workstations.pagers.ListUsableWorkstationConfigsAsyncPager: @@ -1289,7 +1337,7 @@ async def create_workstation_config( workstation_config_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 workstation configuration. @@ -1348,8 +1396,10 @@ async def sample_create_workstation_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: @@ -1440,7 +1490,7 @@ async def update_workstation_config( 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 an existing workstation configuration. @@ -1493,8 +1543,10 @@ async def sample_update_workstation_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: @@ -1584,7 +1636,7 @@ async def delete_workstation_config( name: Optional[str] = None, retry: OptionalRetry = gapic_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 workstation configuration. @@ -1632,8 +1684,10 @@ async def sample_delete_workstation_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: @@ -1717,7 +1771,7 @@ async def get_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.Workstation: r"""Returns the requested workstation. @@ -1760,8 +1814,10 @@ async def sample_get_workstation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workstations_v1.types.Workstation: @@ -1823,7 +1879,7 @@ async def list_workstations( 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.ListWorkstationsAsyncPager: r"""Returns all Workstations using the specified workstation configuration. @@ -1866,8 +1922,10 @@ async def sample_list_workstations(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workstations_v1.services.workstations.pagers.ListWorkstationsAsyncPager: @@ -1944,7 +2002,7 @@ async def list_usable_workstations( 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.ListUsableWorkstationsAsyncPager: r"""Returns all workstations using the specified workstation configuration on which the caller has the @@ -1989,8 +2047,10 @@ async def sample_list_usable_workstations(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workstations_v1.services.workstations.pagers.ListUsableWorkstationsAsyncPager: @@ -2067,7 +2127,7 @@ async def create_workstation( workstation_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 workstation. @@ -2126,8 +2186,10 @@ async def sample_create_workstation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2205,7 +2267,7 @@ async def update_workstation( 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 an existing workstation. @@ -2258,8 +2320,10 @@ async def sample_update_workstation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2336,7 +2400,7 @@ async def delete_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_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 workstation. @@ -2384,8 +2448,10 @@ async def sample_delete_workstation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2458,7 +2524,7 @@ async def start_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_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"""Starts running a workstation so that users can connect to it. @@ -2506,8 +2572,10 @@ async def sample_start_workstation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2580,7 +2648,7 @@ async def stop_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_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"""Stops running a workstation, reducing costs. @@ -2627,8 +2695,10 @@ async def sample_stop_workstation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2701,7 +2771,7 @@ async def generate_access_token( workstation: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.GenerateAccessTokenResponse: r"""Returns a short-lived credential that can be used to send authenticated and authorized traffic to a @@ -2748,8 +2818,10 @@ async def sample_generate_access_token(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workstations_v1.types.GenerateAccessTokenResponse: @@ -2811,7 +2883,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. @@ -2822,8 +2894,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. @@ -2864,7 +2938,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. @@ -2875,8 +2949,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. @@ -2917,7 +2993,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. @@ -2933,8 +3009,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 """ @@ -2971,7 +3049,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. @@ -2986,8 +3064,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 """ @@ -3024,7 +3104,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. @@ -3037,8 +3117,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. @@ -3143,7 +3225,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. @@ -3157,8 +3239,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. @@ -3263,7 +3347,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. @@ -3278,8 +3362,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-workstations/google/cloud/workstations_v1/services/workstations/client.py b/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/client.py index 671a7e62773b..9d5d5ec5887c 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/client.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/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 @@ -637,6 +647,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( @@ -699,6 +713,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.workstations_v1.WorkstationsClient`.", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "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.workstations.v1.Workstations", + "credentialsType": None, + }, + ) + def get_workstation_cluster( self, request: Optional[ @@ -708,7 +745,7 @@ def get_workstation_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]]] = (), ) -> workstations.WorkstationCluster: r"""Returns the requested workstation cluster. @@ -752,8 +789,10 @@ def sample_get_workstation_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.workstations_v1.types.WorkstationCluster: @@ -816,7 +855,7 @@ def list_workstation_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.ListWorkstationClustersPager: r"""Returns all workstation clusters in the specified location. @@ -860,8 +899,10 @@ def sample_list_workstation_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.workstations_v1.services.workstations.pagers.ListWorkstationClustersPager: @@ -939,7 +980,7 @@ def create_workstation_cluster( workstation_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 workstation cluster. @@ -1000,8 +1041,10 @@ def sample_create_workstation_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: @@ -1085,7 +1128,7 @@ def update_workstation_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 an existing workstation cluster. @@ -1140,8 +1183,10 @@ def sample_update_workstation_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: @@ -1222,7 +1267,7 @@ def delete_workstation_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 the specified workstation cluster. @@ -1270,8 +1315,10 @@ def sample_delete_workstation_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: @@ -1346,7 +1393,7 @@ def get_workstation_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.WorkstationConfig: r"""Returns the requested workstation configuration. @@ -1390,8 +1437,10 @@ def sample_get_workstation_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.workstations_v1.types.WorkstationConfig: @@ -1462,7 +1511,7 @@ def list_workstation_configs( 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.ListWorkstationConfigsPager: r"""Returns all workstation configurations in the specified cluster. @@ -1506,8 +1555,10 @@ def sample_list_workstation_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.workstations_v1.services.workstations.pagers.ListWorkstationConfigsPager: @@ -1581,7 +1632,7 @@ def list_usable_workstation_configs( 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.ListUsableWorkstationConfigsPager: r"""Returns all workstation configurations in the specified cluster on which the caller has the @@ -1626,8 +1677,10 @@ def sample_list_usable_workstation_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.workstations_v1.services.workstations.pagers.ListUsableWorkstationConfigsPager: @@ -1705,7 +1758,7 @@ def create_workstation_config( workstation_config_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 workstation configuration. @@ -1764,8 +1817,10 @@ def sample_create_workstation_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: @@ -1855,7 +1910,7 @@ def update_workstation_config( 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 an existing workstation configuration. @@ -1908,8 +1963,10 @@ def sample_update_workstation_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: @@ -1998,7 +2055,7 @@ def delete_workstation_config( name: Optional[str] = None, retry: OptionalRetry = gapic_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 workstation configuration. @@ -2046,8 +2103,10 @@ def sample_delete_workstation_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: @@ -2130,7 +2189,7 @@ def get_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.Workstation: r"""Returns the requested workstation. @@ -2173,8 +2232,10 @@ def sample_get_workstation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workstations_v1.types.Workstation: @@ -2233,7 +2294,7 @@ def list_workstations( 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.ListWorkstationsPager: r"""Returns all Workstations using the specified workstation configuration. @@ -2276,8 +2337,10 @@ def sample_list_workstations(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workstations_v1.services.workstations.pagers.ListWorkstationsPager: @@ -2351,7 +2414,7 @@ def list_usable_workstations( 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.ListUsableWorkstationsPager: r"""Returns all workstations using the specified workstation configuration on which the caller has the @@ -2396,8 +2459,10 @@ def sample_list_usable_workstations(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workstations_v1.services.workstations.pagers.ListUsableWorkstationsPager: @@ -2471,7 +2536,7 @@ def create_workstation( workstation_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 workstation. @@ -2530,8 +2595,10 @@ def sample_create_workstation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2606,7 +2673,7 @@ def update_workstation( 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 an existing workstation. @@ -2659,8 +2726,10 @@ def sample_update_workstation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2734,7 +2803,7 @@ def delete_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_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 workstation. @@ -2782,8 +2851,10 @@ def sample_delete_workstation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2853,7 +2924,7 @@ def start_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_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"""Starts running a workstation so that users can connect to it. @@ -2901,8 +2972,10 @@ def sample_start_workstation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2972,7 +3045,7 @@ def stop_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_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"""Stops running a workstation, reducing costs. @@ -3019,8 +3092,10 @@ def sample_stop_workstation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3090,7 +3165,7 @@ def generate_access_token( workstation: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.GenerateAccessTokenResponse: r"""Returns a short-lived credential that can be used to send authenticated and authorized traffic to a @@ -3137,8 +3212,10 @@ def sample_generate_access_token(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workstations_v1.types.GenerateAccessTokenResponse: @@ -3210,7 +3287,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. @@ -3221,8 +3298,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. @@ -3263,7 +3342,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. @@ -3274,8 +3353,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. @@ -3316,7 +3397,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. @@ -3332,8 +3413,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 """ @@ -3370,7 +3453,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. @@ -3385,8 +3468,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 """ @@ -3423,7 +3508,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. @@ -3436,8 +3521,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. @@ -3542,7 +3629,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. @@ -3556,8 +3643,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. @@ -3662,7 +3751,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. @@ -3677,8 +3766,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-workstations/google/cloud/workstations_v1/services/workstations/pagers.py b/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/pagers.py index bdbc71e10efc..8783a693eef7 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/pagers.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/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 = workstations.ListWorkstationClustersRequest(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 = workstations.ListWorkstationClustersRequest(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 = workstations.ListWorkstationConfigsRequest(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 = workstations.ListWorkstationConfigsRequest(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 = workstations.ListUsableWorkstationConfigsRequest(request) @@ -449,7 +459,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. @@ -463,8 +473,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 = workstations.ListUsableWorkstationConfigsRequest(request) @@ -529,7 +541,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -543,8 +555,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = workstations.ListWorkstationsRequest(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 = workstations.ListWorkstationsRequest(request) @@ -681,7 +697,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -695,8 +711,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = workstations.ListUsableWorkstationsRequest(request) @@ -755,7 +773,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. @@ -769,8 +787,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 = workstations.ListUsableWorkstationsRequest(request) diff --git a/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/transports/grpc.py b/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/transports/grpc.py index e0888846d807..04fee83dc51f 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/transports/grpc.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/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.workstations_v1.types import workstations from .base import DEFAULT_CLIENT_INFO, WorkstationsTransport +try: + from google.api_core import client_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.workstations.v1.Workstations", + "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.workstations.v1.Workstations", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WorkstationsGrpcTransport(WorkstationsTransport): """gRPC backend transport for Workstations. @@ -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_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workstation_cluster" not in self._stubs: - self._stubs["get_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_workstation_cluster"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/GetWorkstationCluster", request_serializer=workstations.GetWorkstationClusterRequest.serialize, response_deserializer=workstations.WorkstationCluster.deserialize, @@ -304,7 +392,7 @@ def list_workstation_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workstation_clusters" not in self._stubs: - self._stubs["list_workstation_clusters"] = self.grpc_channel.unary_unary( + self._stubs["list_workstation_clusters"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/ListWorkstationClusters", request_serializer=workstations.ListWorkstationClustersRequest.serialize, response_deserializer=workstations.ListWorkstationClustersResponse.deserialize, @@ -332,7 +420,9 @@ def create_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workstation_cluster" not in self._stubs: - self._stubs["create_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_workstation_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/CreateWorkstationCluster", request_serializer=workstations.CreateWorkstationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -360,7 +450,9 @@ def update_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workstation_cluster" not in self._stubs: - self._stubs["update_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_workstation_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/UpdateWorkstationCluster", request_serializer=workstations.UpdateWorkstationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -388,7 +480,9 @@ def delete_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workstation_cluster" not in self._stubs: - self._stubs["delete_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_workstation_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/DeleteWorkstationCluster", request_serializer=workstations.DeleteWorkstationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -416,7 +510,7 @@ def get_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workstation_config" not in self._stubs: - self._stubs["get_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["get_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/GetWorkstationConfig", request_serializer=workstations.GetWorkstationConfigRequest.serialize, response_deserializer=workstations.WorkstationConfig.deserialize, @@ -446,7 +540,7 @@ def list_workstation_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workstation_configs" not in self._stubs: - self._stubs["list_workstation_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_workstation_configs"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/ListWorkstationConfigs", request_serializer=workstations.ListWorkstationConfigsRequest.serialize, response_deserializer=workstations.ListWorkstationConfigsResponse.deserialize, @@ -480,7 +574,7 @@ def list_usable_workstation_configs( if "list_usable_workstation_configs" not in self._stubs: self._stubs[ "list_usable_workstation_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/ListUsableWorkstationConfigs", request_serializer=workstations.ListUsableWorkstationConfigsRequest.serialize, response_deserializer=workstations.ListUsableWorkstationConfigsResponse.deserialize, @@ -508,7 +602,7 @@ def create_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workstation_config" not in self._stubs: - self._stubs["create_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["create_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/CreateWorkstationConfig", request_serializer=workstations.CreateWorkstationConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -536,7 +630,7 @@ def update_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workstation_config" not in self._stubs: - self._stubs["update_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["update_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/UpdateWorkstationConfig", request_serializer=workstations.UpdateWorkstationConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -564,7 +658,7 @@ def delete_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workstation_config" not in self._stubs: - self._stubs["delete_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/DeleteWorkstationConfig", request_serializer=workstations.DeleteWorkstationConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -590,7 +684,7 @@ def get_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workstation" not in self._stubs: - self._stubs["get_workstation"] = self.grpc_channel.unary_unary( + self._stubs["get_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/GetWorkstation", request_serializer=workstations.GetWorkstationRequest.serialize, response_deserializer=workstations.Workstation.deserialize, @@ -619,7 +713,7 @@ def list_workstations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workstations" not in self._stubs: - self._stubs["list_workstations"] = self.grpc_channel.unary_unary( + self._stubs["list_workstations"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/ListWorkstations", request_serializer=workstations.ListWorkstationsRequest.serialize, response_deserializer=workstations.ListWorkstationsResponse.deserialize, @@ -650,7 +744,7 @@ def list_usable_workstations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_usable_workstations" not in self._stubs: - self._stubs["list_usable_workstations"] = self.grpc_channel.unary_unary( + self._stubs["list_usable_workstations"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/ListUsableWorkstations", request_serializer=workstations.ListUsableWorkstationsRequest.serialize, response_deserializer=workstations.ListUsableWorkstationsResponse.deserialize, @@ -676,7 +770,7 @@ def create_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workstation" not in self._stubs: - self._stubs["create_workstation"] = self.grpc_channel.unary_unary( + self._stubs["create_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/CreateWorkstation", request_serializer=workstations.CreateWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -702,7 +796,7 @@ def update_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workstation" not in self._stubs: - self._stubs["update_workstation"] = self.grpc_channel.unary_unary( + self._stubs["update_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/UpdateWorkstation", request_serializer=workstations.UpdateWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -728,7 +822,7 @@ def delete_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workstation" not in self._stubs: - self._stubs["delete_workstation"] = self.grpc_channel.unary_unary( + self._stubs["delete_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/DeleteWorkstation", request_serializer=workstations.DeleteWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -755,7 +849,7 @@ def start_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_workstation" not in self._stubs: - self._stubs["start_workstation"] = self.grpc_channel.unary_unary( + self._stubs["start_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/StartWorkstation", request_serializer=workstations.StartWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -781,7 +875,7 @@ def stop_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_workstation" not in self._stubs: - self._stubs["stop_workstation"] = self.grpc_channel.unary_unary( + self._stubs["stop_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/StopWorkstation", request_serializer=workstations.StopWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -812,7 +906,7 @@ def generate_access_token( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_access_token" not in self._stubs: - self._stubs["generate_access_token"] = self.grpc_channel.unary_unary( + self._stubs["generate_access_token"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/GenerateAccessToken", request_serializer=workstations.GenerateAccessTokenRequest.serialize, response_deserializer=workstations.GenerateAccessTokenResponse.deserialize, @@ -820,7 +914,7 @@ def generate_access_token( return self._stubs["generate_access_token"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -832,7 +926,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, @@ -849,7 +943,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, @@ -866,7 +960,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, @@ -885,7 +979,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, @@ -910,7 +1004,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, @@ -936,7 +1030,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, @@ -965,7 +1059,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-workstations/google/cloud/workstations_v1/services/workstations/transports/grpc_asyncio.py b/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/transports/grpc_asyncio.py index f8facb31e37b..fc4de3587a08 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/transports/grpc_asyncio.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/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.workstations_v1.types import workstations from .base import DEFAULT_CLIENT_INFO, WorkstationsTransport from .grpc import WorkstationsGrpcTransport +try: + from google.api_core import client_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.workstations.v1.Workstations", + "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.workstations.v1.Workstations", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WorkstationsGrpcAsyncIOTransport(WorkstationsTransport): """gRPC AsyncIO backend transport for Workstations. @@ -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_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workstation_cluster" not in self._stubs: - self._stubs["get_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_workstation_cluster"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/GetWorkstationCluster", request_serializer=workstations.GetWorkstationClusterRequest.serialize, response_deserializer=workstations.WorkstationCluster.deserialize, @@ -315,7 +400,7 @@ def list_workstation_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workstation_clusters" not in self._stubs: - self._stubs["list_workstation_clusters"] = self.grpc_channel.unary_unary( + self._stubs["list_workstation_clusters"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/ListWorkstationClusters", request_serializer=workstations.ListWorkstationClustersRequest.serialize, response_deserializer=workstations.ListWorkstationClustersResponse.deserialize, @@ -344,7 +429,9 @@ def create_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workstation_cluster" not in self._stubs: - self._stubs["create_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_workstation_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/CreateWorkstationCluster", request_serializer=workstations.CreateWorkstationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -373,7 +460,9 @@ def update_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workstation_cluster" not in self._stubs: - self._stubs["update_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_workstation_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/UpdateWorkstationCluster", request_serializer=workstations.UpdateWorkstationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -402,7 +491,9 @@ def delete_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workstation_cluster" not in self._stubs: - self._stubs["delete_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_workstation_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/DeleteWorkstationCluster", request_serializer=workstations.DeleteWorkstationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -431,7 +522,7 @@ def get_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workstation_config" not in self._stubs: - self._stubs["get_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["get_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/GetWorkstationConfig", request_serializer=workstations.GetWorkstationConfigRequest.serialize, response_deserializer=workstations.WorkstationConfig.deserialize, @@ -461,7 +552,7 @@ def list_workstation_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workstation_configs" not in self._stubs: - self._stubs["list_workstation_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_workstation_configs"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/ListWorkstationConfigs", request_serializer=workstations.ListWorkstationConfigsRequest.serialize, response_deserializer=workstations.ListWorkstationConfigsResponse.deserialize, @@ -495,7 +586,7 @@ def list_usable_workstation_configs( if "list_usable_workstation_configs" not in self._stubs: self._stubs[ "list_usable_workstation_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/ListUsableWorkstationConfigs", request_serializer=workstations.ListUsableWorkstationConfigsRequest.serialize, response_deserializer=workstations.ListUsableWorkstationConfigsResponse.deserialize, @@ -524,7 +615,7 @@ def create_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workstation_config" not in self._stubs: - self._stubs["create_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["create_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/CreateWorkstationConfig", request_serializer=workstations.CreateWorkstationConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -553,7 +644,7 @@ def update_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workstation_config" not in self._stubs: - self._stubs["update_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["update_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/UpdateWorkstationConfig", request_serializer=workstations.UpdateWorkstationConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -582,7 +673,7 @@ def delete_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workstation_config" not in self._stubs: - self._stubs["delete_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/DeleteWorkstationConfig", request_serializer=workstations.DeleteWorkstationConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -610,7 +701,7 @@ def get_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workstation" not in self._stubs: - self._stubs["get_workstation"] = self.grpc_channel.unary_unary( + self._stubs["get_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/GetWorkstation", request_serializer=workstations.GetWorkstationRequest.serialize, response_deserializer=workstations.Workstation.deserialize, @@ -640,7 +731,7 @@ def list_workstations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workstations" not in self._stubs: - self._stubs["list_workstations"] = self.grpc_channel.unary_unary( + self._stubs["list_workstations"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/ListWorkstations", request_serializer=workstations.ListWorkstationsRequest.serialize, response_deserializer=workstations.ListWorkstationsResponse.deserialize, @@ -671,7 +762,7 @@ def list_usable_workstations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_usable_workstations" not in self._stubs: - self._stubs["list_usable_workstations"] = self.grpc_channel.unary_unary( + self._stubs["list_usable_workstations"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/ListUsableWorkstations", request_serializer=workstations.ListUsableWorkstationsRequest.serialize, response_deserializer=workstations.ListUsableWorkstationsResponse.deserialize, @@ -699,7 +790,7 @@ def create_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workstation" not in self._stubs: - self._stubs["create_workstation"] = self.grpc_channel.unary_unary( + self._stubs["create_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/CreateWorkstation", request_serializer=workstations.CreateWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -727,7 +818,7 @@ def update_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workstation" not in self._stubs: - self._stubs["update_workstation"] = self.grpc_channel.unary_unary( + self._stubs["update_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/UpdateWorkstation", request_serializer=workstations.UpdateWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -755,7 +846,7 @@ def delete_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workstation" not in self._stubs: - self._stubs["delete_workstation"] = self.grpc_channel.unary_unary( + self._stubs["delete_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/DeleteWorkstation", request_serializer=workstations.DeleteWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -784,7 +875,7 @@ def start_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_workstation" not in self._stubs: - self._stubs["start_workstation"] = self.grpc_channel.unary_unary( + self._stubs["start_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/StartWorkstation", request_serializer=workstations.StartWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -812,7 +903,7 @@ def stop_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_workstation" not in self._stubs: - self._stubs["stop_workstation"] = self.grpc_channel.unary_unary( + self._stubs["stop_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/StopWorkstation", request_serializer=workstations.StopWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -843,7 +934,7 @@ def generate_access_token( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_access_token" not in self._stubs: - self._stubs["generate_access_token"] = self.grpc_channel.unary_unary( + self._stubs["generate_access_token"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/GenerateAccessToken", request_serializer=workstations.GenerateAccessTokenRequest.serialize, response_deserializer=workstations.GenerateAccessTokenResponse.deserialize, @@ -1077,7 +1168,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: @@ -1093,7 +1184,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, @@ -1110,7 +1201,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, @@ -1127,7 +1218,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, @@ -1146,7 +1237,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, @@ -1171,7 +1262,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, @@ -1197,7 +1288,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, @@ -1226,7 +1317,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-workstations/google/cloud/workstations_v1/services/workstations/transports/rest.py b/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/transports/rest.py index e14a7d180d16..c02f4ce26b68 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/transports/rest.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/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, @@ -233,8 +241,10 @@ def post_update_workstation_config(self, response): def pre_create_workstation( self, request: workstations.CreateWorkstationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.CreateWorkstationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.CreateWorkstationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_workstation Override in a subclass to manipulate the request or metadata @@ -256,8 +266,11 @@ def post_create_workstation( def pre_create_workstation_cluster( self, request: workstations.CreateWorkstationClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.CreateWorkstationClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.CreateWorkstationClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_workstation_cluster Override in a subclass to manipulate the request or metadata @@ -279,8 +292,11 @@ def post_create_workstation_cluster( def pre_create_workstation_config( self, request: workstations.CreateWorkstationConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.CreateWorkstationConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.CreateWorkstationConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_workstation_config Override in a subclass to manipulate the request or metadata @@ -302,8 +318,10 @@ def post_create_workstation_config( def pre_delete_workstation( self, request: workstations.DeleteWorkstationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.DeleteWorkstationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.DeleteWorkstationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_workstation Override in a subclass to manipulate the request or metadata @@ -325,8 +343,11 @@ def post_delete_workstation( def pre_delete_workstation_cluster( self, request: workstations.DeleteWorkstationClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.DeleteWorkstationClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.DeleteWorkstationClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_workstation_cluster Override in a subclass to manipulate the request or metadata @@ -348,8 +369,11 @@ def post_delete_workstation_cluster( def pre_delete_workstation_config( self, request: workstations.DeleteWorkstationConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.DeleteWorkstationConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.DeleteWorkstationConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_workstation_config Override in a subclass to manipulate the request or metadata @@ -371,8 +395,10 @@ def post_delete_workstation_config( def pre_generate_access_token( self, request: workstations.GenerateAccessTokenRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.GenerateAccessTokenRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.GenerateAccessTokenRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for generate_access_token Override in a subclass to manipulate the request or metadata @@ -394,8 +420,10 @@ def post_generate_access_token( def pre_get_workstation( self, request: workstations.GetWorkstationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.GetWorkstationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.GetWorkstationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_workstation Override in a subclass to manipulate the request or metadata @@ -417,8 +445,11 @@ def post_get_workstation( def pre_get_workstation_cluster( self, request: workstations.GetWorkstationClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.GetWorkstationClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.GetWorkstationClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_workstation_cluster Override in a subclass to manipulate the request or metadata @@ -440,8 +471,11 @@ def post_get_workstation_cluster( def pre_get_workstation_config( self, request: workstations.GetWorkstationConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.GetWorkstationConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.GetWorkstationConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_workstation_config Override in a subclass to manipulate the request or metadata @@ -463,9 +497,10 @@ def post_get_workstation_config( def pre_list_usable_workstation_configs( self, request: workstations.ListUsableWorkstationConfigsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - workstations.ListUsableWorkstationConfigsRequest, Sequence[Tuple[str, str]] + workstations.ListUsableWorkstationConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_usable_workstation_configs @@ -488,8 +523,11 @@ def post_list_usable_workstation_configs( def pre_list_usable_workstations( self, request: workstations.ListUsableWorkstationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.ListUsableWorkstationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.ListUsableWorkstationsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_usable_workstations Override in a subclass to manipulate the request or metadata @@ -511,8 +549,11 @@ def post_list_usable_workstations( def pre_list_workstation_clusters( self, request: workstations.ListWorkstationClustersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.ListWorkstationClustersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.ListWorkstationClustersRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_workstation_clusters Override in a subclass to manipulate the request or metadata @@ -534,8 +575,11 @@ def post_list_workstation_clusters( def pre_list_workstation_configs( self, request: workstations.ListWorkstationConfigsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.ListWorkstationConfigsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.ListWorkstationConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_workstation_configs Override in a subclass to manipulate the request or metadata @@ -557,8 +601,10 @@ def post_list_workstation_configs( def pre_list_workstations( self, request: workstations.ListWorkstationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.ListWorkstationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.ListWorkstationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_workstations Override in a subclass to manipulate the request or metadata @@ -580,8 +626,10 @@ def post_list_workstations( def pre_start_workstation( self, request: workstations.StartWorkstationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.StartWorkstationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.StartWorkstationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for start_workstation Override in a subclass to manipulate the request or metadata @@ -603,8 +651,10 @@ def post_start_workstation( def pre_stop_workstation( self, request: workstations.StopWorkstationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.StopWorkstationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.StopWorkstationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for stop_workstation Override in a subclass to manipulate the request or metadata @@ -626,8 +676,10 @@ def post_stop_workstation( def pre_update_workstation( self, request: workstations.UpdateWorkstationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.UpdateWorkstationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.UpdateWorkstationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_workstation Override in a subclass to manipulate the request or metadata @@ -649,8 +701,11 @@ def post_update_workstation( def pre_update_workstation_cluster( self, request: workstations.UpdateWorkstationClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.UpdateWorkstationClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.UpdateWorkstationClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_workstation_cluster Override in a subclass to manipulate the request or metadata @@ -672,8 +727,11 @@ def post_update_workstation_cluster( def pre_update_workstation_config( self, request: workstations.UpdateWorkstationConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.UpdateWorkstationConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.UpdateWorkstationConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_workstation_config Override in a subclass to manipulate the request or metadata @@ -695,8 +753,10 @@ def post_update_workstation_config( 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 @@ -716,8 +776,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 @@ -737,8 +799,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 @@ -760,8 +825,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 @@ -781,8 +848,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 @@ -802,8 +871,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 @@ -825,8 +896,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 @@ -1021,7 +1094,7 @@ 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 workstation method over HTTP. @@ -1032,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.Operation: @@ -1046,6 +1121,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseCreateWorkstation._get_http_options() ) + request, metadata = self._interceptor.pre_create_workstation( request, metadata ) @@ -1062,6 +1138,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.CreateWorkstation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "CreateWorkstation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._CreateWorkstation._get_response( self._host, @@ -1081,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_create_workstation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1.WorkstationsClient.create_workstation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "CreateWorkstation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateWorkstationCluster( @@ -1120,7 +1245,7 @@ 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 workstation cluster method over HTTP. @@ -1132,8 +1257,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1146,6 +1273,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseCreateWorkstationCluster._get_http_options() ) + request, metadata = self._interceptor.pre_create_workstation_cluster( request, metadata ) @@ -1162,6 +1290,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.CreateWorkstationCluster", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "CreateWorkstationCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( WorkstationsRestTransport._CreateWorkstationCluster._get_response( @@ -1183,7 +1338,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_workstation_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.workstations_v1.WorkstationsClient.create_workstation_cluster", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "CreateWorkstationCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateWorkstationConfig( @@ -1222,7 +1399,7 @@ 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 workstation config method over HTTP. @@ -1233,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: ~.operations_pb2.Operation: @@ -1247,6 +1426,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseCreateWorkstationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_workstation_config( request, metadata ) @@ -1263,6 +1443,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.CreateWorkstationConfig", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "CreateWorkstationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._CreateWorkstationConfig._get_response( self._host, @@ -1282,7 +1489,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_workstation_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.workstations_v1.WorkstationsClient.create_workstation_config", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "CreateWorkstationConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteWorkstation( @@ -1319,7 +1548,7 @@ 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 workstation method over HTTP. @@ -1330,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: ~.operations_pb2.Operation: @@ -1344,6 +1575,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseDeleteWorkstation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_workstation( request, metadata ) @@ -1356,6 +1588,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.DeleteWorkstation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "DeleteWorkstation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._DeleteWorkstation._get_response( self._host, @@ -1374,7 +1633,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_workstation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1.WorkstationsClient.delete_workstation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "DeleteWorkstation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteWorkstationCluster( @@ -1412,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete workstation cluster method over HTTP. @@ -1424,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: ~.operations_pb2.Operation: @@ -1438,6 +1721,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseDeleteWorkstationCluster._get_http_options() ) + request, metadata = self._interceptor.pre_delete_workstation_cluster( request, metadata ) @@ -1450,6 +1734,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.DeleteWorkstationCluster", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "DeleteWorkstationCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( WorkstationsRestTransport._DeleteWorkstationCluster._get_response( @@ -1470,7 +1781,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_workstation_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.workstations_v1.WorkstationsClient.delete_workstation_cluster", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "DeleteWorkstationCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteWorkstationConfig( @@ -1508,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete workstation config method over HTTP. @@ -1519,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: ~.operations_pb2.Operation: @@ -1533,6 +1868,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseDeleteWorkstationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_workstation_config( request, metadata ) @@ -1545,6 +1881,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.DeleteWorkstationConfig", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "DeleteWorkstationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._DeleteWorkstationConfig._get_response( self._host, @@ -1563,7 +1926,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_workstation_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.workstations_v1.WorkstationsClient.delete_workstation_config", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "DeleteWorkstationConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateAccessToken( @@ -1601,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]]] = (), ) -> workstations.GenerateAccessTokenResponse: r"""Call the generate access token method over HTTP. @@ -1612,8 +1997,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.workstations.GenerateAccessTokenResponse: @@ -1625,6 +2012,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseGenerateAccessToken._get_http_options() ) + request, metadata = self._interceptor.pre_generate_access_token( request, metadata ) @@ -1641,6 +2029,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.GenerateAccessToken", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "GenerateAccessToken", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._GenerateAccessToken._get_response( self._host, @@ -1662,7 +2077,31 @@ def __call__( pb_resp = workstations.GenerateAccessTokenResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_access_token(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workstations.GenerateAccessTokenResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1.WorkstationsClient.generate_access_token", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "GenerateAccessToken", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetWorkstation( @@ -1699,7 +2138,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.Workstation: r"""Call the get workstation method over HTTP. @@ -1709,8 +2148,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.workstations.Workstation: @@ -1723,6 +2164,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseGetWorkstation._get_http_options() ) + request, metadata = self._interceptor.pre_get_workstation(request, metadata) transcoded_request = _BaseWorkstationsRestTransport._BaseGetWorkstation._get_transcoded_request( http_options, request @@ -1733,6 +2175,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.GetWorkstation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "GetWorkstation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._GetWorkstation._get_response( self._host, @@ -1753,7 +2222,29 @@ def __call__( pb_resp = workstations.Workstation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_workstation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workstations.Workstation.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1.WorkstationsClient.get_workstation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "GetWorkstation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetWorkstationCluster( @@ -1790,7 +2281,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.WorkstationCluster: r"""Call the get workstation cluster method over HTTP. @@ -1801,8 +2292,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.workstations.WorkstationCluster: @@ -1817,6 +2310,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseGetWorkstationCluster._get_http_options() ) + request, metadata = self._interceptor.pre_get_workstation_cluster( request, metadata ) @@ -1829,6 +2323,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.GetWorkstationCluster", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "GetWorkstationCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._GetWorkstationCluster._get_response( self._host, @@ -1849,7 +2370,29 @@ def __call__( pb_resp = workstations.WorkstationCluster.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_workstation_cluster(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workstations.WorkstationCluster.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1.WorkstationsClient.get_workstation_cluster", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "GetWorkstationCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetWorkstationConfig( @@ -1886,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]]] = (), ) -> workstations.WorkstationConfig: r"""Call the get workstation config method over HTTP. @@ -1897,8 +2440,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.workstations.WorkstationConfig: @@ -1921,6 +2466,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseGetWorkstationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_workstation_config( request, metadata ) @@ -1933,6 +2479,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.GetWorkstationConfig", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "GetWorkstationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._GetWorkstationConfig._get_response( self._host, @@ -1953,7 +2526,29 @@ def __call__( pb_resp = workstations.WorkstationConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_workstation_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workstations.WorkstationConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1.WorkstationsClient.get_workstation_config", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "GetWorkstationConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListUsableWorkstationConfigs( @@ -1991,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]]] = (), ) -> workstations.ListUsableWorkstationConfigsResponse: r"""Call the list usable workstation configs method over HTTP. @@ -2003,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: ~.workstations.ListUsableWorkstationConfigsResponse: @@ -2016,6 +2613,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseListUsableWorkstationConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_usable_workstation_configs( request, metadata ) @@ -2028,6 +2626,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.ListUsableWorkstationConfigs", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "ListUsableWorkstationConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( WorkstationsRestTransport._ListUsableWorkstationConfigs._get_response( @@ -2050,7 +2675,33 @@ def __call__( pb_resp = workstations.ListUsableWorkstationConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_usable_workstation_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + workstations.ListUsableWorkstationConfigsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1.WorkstationsClient.list_usable_workstation_configs", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "ListUsableWorkstationConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListUsableWorkstations( @@ -2087,7 +2738,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.ListUsableWorkstationsResponse: r"""Call the list usable workstations method over HTTP. @@ -2098,8 +2749,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.workstations.ListUsableWorkstationsResponse: @@ -2111,6 +2764,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseListUsableWorkstations._get_http_options() ) + request, metadata = self._interceptor.pre_list_usable_workstations( request, metadata ) @@ -2123,6 +2777,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.ListUsableWorkstations", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "ListUsableWorkstations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._ListUsableWorkstations._get_response( self._host, @@ -2143,7 +2824,31 @@ def __call__( pb_resp = workstations.ListUsableWorkstationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_usable_workstations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + workstations.ListUsableWorkstationsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1.WorkstationsClient.list_usable_workstations", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "ListUsableWorkstations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListWorkstationClusters( @@ -2181,7 +2886,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.ListWorkstationClustersResponse: r"""Call the list workstation clusters method over HTTP. @@ -2192,8 +2897,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.workstations.ListWorkstationClustersResponse: @@ -2205,6 +2912,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseListWorkstationClusters._get_http_options() ) + request, metadata = self._interceptor.pre_list_workstation_clusters( request, metadata ) @@ -2217,6 +2925,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.ListWorkstationClusters", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "ListWorkstationClusters", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._ListWorkstationClusters._get_response( self._host, @@ -2237,7 +2972,31 @@ def __call__( pb_resp = workstations.ListWorkstationClustersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_workstation_clusters(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + workstations.ListWorkstationClustersResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1.WorkstationsClient.list_workstation_clusters", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "ListWorkstationClusters", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListWorkstationConfigs( @@ -2274,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]]] = (), ) -> workstations.ListWorkstationConfigsResponse: r"""Call the list workstation configs method over HTTP. @@ -2285,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: ~.workstations.ListWorkstationConfigsResponse: @@ -2298,6 +3059,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseListWorkstationConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_workstation_configs( request, metadata ) @@ -2310,6 +3072,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.ListWorkstationConfigs", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "ListWorkstationConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._ListWorkstationConfigs._get_response( self._host, @@ -2330,7 +3119,31 @@ def __call__( pb_resp = workstations.ListWorkstationConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_workstation_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + workstations.ListWorkstationConfigsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1.WorkstationsClient.list_workstation_configs", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "ListWorkstationConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListWorkstations( @@ -2367,7 +3180,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.ListWorkstationsResponse: r"""Call the list workstations method over HTTP. @@ -2377,8 +3190,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.workstations.ListWorkstationsResponse: @@ -2390,6 +3205,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseListWorkstations._get_http_options() ) + request, metadata = self._interceptor.pre_list_workstations( request, metadata ) @@ -2402,6 +3218,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.ListWorkstations", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "ListWorkstations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._ListWorkstations._get_response( self._host, @@ -2422,7 +3265,31 @@ def __call__( pb_resp = workstations.ListWorkstationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_workstations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workstations.ListWorkstationsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1.WorkstationsClient.list_workstations", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "ListWorkstations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StartWorkstation( @@ -2460,7 +3327,7 @@ 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 start workstation method over HTTP. @@ -2470,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: ~.operations_pb2.Operation: @@ -2484,6 +3353,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseStartWorkstation._get_http_options() ) + request, metadata = self._interceptor.pre_start_workstation( request, metadata ) @@ -2500,6 +3370,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.StartWorkstation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "StartWorkstation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._StartWorkstation._get_response( self._host, @@ -2519,7 +3416,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_start_workstation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1.WorkstationsClient.start_workstation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "StartWorkstation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StopWorkstation( @@ -2557,7 +3476,7 @@ 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 stop workstation method over HTTP. @@ -2567,8 +3486,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2581,6 +3502,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseStopWorkstation._get_http_options() ) + request, metadata = self._interceptor.pre_stop_workstation( request, metadata ) @@ -2597,6 +3519,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.StopWorkstation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "StopWorkstation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._StopWorkstation._get_response( self._host, @@ -2616,7 +3565,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_stop_workstation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1.WorkstationsClient.stop_workstation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "StopWorkstation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateWorkstation( @@ -2654,7 +3625,7 @@ 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 workstation method over HTTP. @@ -2665,8 +3636,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2679,6 +3652,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseUpdateWorkstation._get_http_options() ) + request, metadata = self._interceptor.pre_update_workstation( request, metadata ) @@ -2695,6 +3669,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.UpdateWorkstation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "UpdateWorkstation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._UpdateWorkstation._get_response( self._host, @@ -2714,7 +3715,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_workstation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1.WorkstationsClient.update_workstation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "UpdateWorkstation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateWorkstationCluster( @@ -2753,7 +3776,7 @@ 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 workstation cluster method over HTTP. @@ -2765,8 +3788,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2779,6 +3804,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseUpdateWorkstationCluster._get_http_options() ) + request, metadata = self._interceptor.pre_update_workstation_cluster( request, metadata ) @@ -2795,6 +3821,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.UpdateWorkstationCluster", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "UpdateWorkstationCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( WorkstationsRestTransport._UpdateWorkstationCluster._get_response( @@ -2816,7 +3869,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_workstation_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.workstations_v1.WorkstationsClient.update_workstation_cluster", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "UpdateWorkstationCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateWorkstationConfig( @@ -2855,7 +3930,7 @@ 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 workstation config method over HTTP. @@ -2866,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: ~.operations_pb2.Operation: @@ -2880,6 +3957,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseUpdateWorkstationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_workstation_config( request, metadata ) @@ -2896,6 +3974,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.UpdateWorkstationConfig", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "UpdateWorkstationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._UpdateWorkstationConfig._get_response( self._host, @@ -2915,7 +4020,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_workstation_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.workstations_v1.WorkstationsClient.update_workstation_config", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "UpdateWorkstationConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -3149,7 +4276,7 @@ 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. @@ -3159,8 +4286,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -3169,6 +4298,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseWorkstationsRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -3181,6 +4311,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._GetIamPolicy._get_response( self._host, @@ -3200,6 +4357,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.workstations_v1.WorkstationsAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3241,7 +4419,7 @@ 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. @@ -3251,8 +4429,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -3261,6 +4441,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseWorkstationsRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -3279,6 +4460,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._SetIamPolicy._get_response( self._host, @@ -3299,6 +4507,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.workstations_v1.WorkstationsAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3340,7 +4569,7 @@ 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. @@ -3350,8 +4579,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -3360,6 +4591,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -3376,6 +4608,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._TestIamPermissions._get_response( self._host, @@ -3396,6 +4655,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.workstations_v1.WorkstationsAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3437,7 +4717,7 @@ 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. @@ -3447,13 +4727,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 = ( _BaseWorkstationsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -3470,6 +4753,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._CancelOperation._get_response( self._host, @@ -3526,7 +4836,7 @@ 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. @@ -3536,13 +4846,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 = ( _BaseWorkstationsRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -3555,6 +4868,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._DeleteOperation._get_response( self._host, @@ -3610,7 +4950,7 @@ 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. @@ -3620,8 +4960,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -3630,6 +4972,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseWorkstationsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -3642,6 +4985,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.GetOperation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._GetOperation._get_response( self._host, @@ -3661,6 +5031,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.workstations_v1.WorkstationsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3701,7 +5092,7 @@ 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. @@ -3711,8 +5102,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -3721,6 +5114,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseWorkstationsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -3731,6 +5125,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1.WorkstationsClient.ListOperations", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._ListOperations._get_response( self._host, @@ -3750,6 +5171,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.workstations_v1.WorkstationsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/gapic_version.py b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/gapic_version.py index 2b5369e53dc7..558c8aab67c5 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/gapic_version.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.5.10" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/async_client.py b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/async_client.py index 7085c6243907..75431d479348 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/async_client.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/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, WorkstationsTransport from .transports.grpc_asyncio import WorkstationsGrpcAsyncIOTransport +try: + from google.api_core import client_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 WorkstationsAsyncClient: """Service for interacting with Cloud Workstations.""" @@ -269,6 +279,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.workstations_v1beta.WorkstationsAsyncClient`.", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "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.workstations.v1beta.Workstations", + "credentialsType": None, + }, + ) + async def get_workstation_cluster( self, request: Optional[ @@ -278,7 +310,7 @@ async def get_workstation_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]]] = (), ) -> workstations.WorkstationCluster: r"""Returns the requested workstation cluster. @@ -322,8 +354,10 @@ async def sample_get_workstation_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.workstations_v1beta.types.WorkstationCluster: @@ -389,7 +423,7 @@ async def list_workstation_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.ListWorkstationClustersAsyncPager: r"""Returns all workstation clusters in the specified location. @@ -433,8 +467,10 @@ async def sample_list_workstation_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.workstations_v1beta.services.workstations.pagers.ListWorkstationClustersAsyncPager: @@ -513,7 +549,7 @@ async def create_workstation_cluster( workstation_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 workstation cluster. @@ -574,8 +610,10 @@ async def sample_create_workstation_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: @@ -660,7 +698,7 @@ async def update_workstation_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 an existing workstation cluster. @@ -715,8 +753,10 @@ async def sample_update_workstation_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: @@ -798,7 +838,7 @@ async def delete_workstation_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 the specified workstation cluster. @@ -846,8 +886,10 @@ async def sample_delete_workstation_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 get_workstation_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.WorkstationConfig: r"""Returns the requested workstation configuration. @@ -967,8 +1009,10 @@ async def sample_get_workstation_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.cloud.workstations_v1beta.types.WorkstationConfig: @@ -1042,7 +1086,7 @@ async def list_workstation_configs( 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.ListWorkstationConfigsAsyncPager: r"""Returns all workstation configurations in the specified cluster. @@ -1086,8 +1130,10 @@ async def sample_list_workstation_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.workstations_v1beta.services.workstations.pagers.ListWorkstationConfigsAsyncPager: @@ -1164,7 +1210,7 @@ async def list_usable_workstation_configs( 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.ListUsableWorkstationConfigsAsyncPager: r"""Returns all workstation configurations in the specified cluster on which the caller has the @@ -1209,8 +1255,10 @@ async def sample_list_usable_workstation_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.workstations_v1beta.services.workstations.pagers.ListUsableWorkstationConfigsAsyncPager: @@ -1289,7 +1337,7 @@ async def create_workstation_config( workstation_config_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 workstation configuration. @@ -1348,8 +1396,10 @@ async def sample_create_workstation_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: @@ -1440,7 +1490,7 @@ async def update_workstation_config( 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 an existing workstation configuration. @@ -1493,8 +1543,10 @@ async def sample_update_workstation_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: @@ -1584,7 +1636,7 @@ async def delete_workstation_config( name: Optional[str] = None, retry: OptionalRetry = gapic_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 workstation configuration. @@ -1632,8 +1684,10 @@ async def sample_delete_workstation_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: @@ -1717,7 +1771,7 @@ async def get_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.Workstation: r"""Returns the requested workstation. @@ -1760,8 +1814,10 @@ async def sample_get_workstation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workstations_v1beta.types.Workstation: @@ -1823,7 +1879,7 @@ async def list_workstations( 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.ListWorkstationsAsyncPager: r"""Returns all Workstations using the specified workstation configuration. @@ -1866,8 +1922,10 @@ async def sample_list_workstations(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workstations_v1beta.services.workstations.pagers.ListWorkstationsAsyncPager: @@ -1944,7 +2002,7 @@ async def list_usable_workstations( 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.ListUsableWorkstationsAsyncPager: r"""Returns all workstations using the specified workstation configuration on which the caller has the @@ -1989,8 +2047,10 @@ async def sample_list_usable_workstations(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workstations_v1beta.services.workstations.pagers.ListUsableWorkstationsAsyncPager: @@ -2067,7 +2127,7 @@ async def create_workstation( workstation_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 workstation. @@ -2126,8 +2186,10 @@ async def sample_create_workstation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2205,7 +2267,7 @@ async def update_workstation( 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 an existing workstation. @@ -2258,8 +2320,10 @@ async def sample_update_workstation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2336,7 +2400,7 @@ async def delete_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_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 workstation. @@ -2384,8 +2448,10 @@ async def sample_delete_workstation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2458,7 +2524,7 @@ async def start_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_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"""Starts running a workstation so that users can connect to it. @@ -2506,8 +2572,10 @@ async def sample_start_workstation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2580,7 +2648,7 @@ async def stop_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_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"""Stops running a workstation, reducing costs. @@ -2627,8 +2695,10 @@ async def sample_stop_workstation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2701,7 +2771,7 @@ async def generate_access_token( workstation: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.GenerateAccessTokenResponse: r"""Returns a short-lived credential that can be used to send authenticated and authorized traffic to a @@ -2748,8 +2818,10 @@ async def sample_generate_access_token(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workstations_v1beta.types.GenerateAccessTokenResponse: @@ -2811,7 +2883,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. @@ -2822,8 +2894,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. @@ -2864,7 +2938,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. @@ -2875,8 +2949,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. @@ -2917,7 +2993,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. @@ -2933,8 +3009,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 """ @@ -2971,7 +3049,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. @@ -2986,8 +3064,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 """ @@ -3024,7 +3104,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. @@ -3037,8 +3117,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. @@ -3143,7 +3225,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. @@ -3157,8 +3239,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. @@ -3263,7 +3347,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. @@ -3278,8 +3362,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-workstations/google/cloud/workstations_v1beta/services/workstations/client.py b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/client.py index 237884ba8624..88bbd9e36357 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/client.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/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 @@ -637,6 +647,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( @@ -699,6 +713,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.workstations_v1beta.WorkstationsClient`.", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "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.workstations.v1beta.Workstations", + "credentialsType": None, + }, + ) + def get_workstation_cluster( self, request: Optional[ @@ -708,7 +745,7 @@ def get_workstation_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]]] = (), ) -> workstations.WorkstationCluster: r"""Returns the requested workstation cluster. @@ -752,8 +789,10 @@ def sample_get_workstation_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.workstations_v1beta.types.WorkstationCluster: @@ -816,7 +855,7 @@ def list_workstation_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.ListWorkstationClustersPager: r"""Returns all workstation clusters in the specified location. @@ -860,8 +899,10 @@ def sample_list_workstation_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.workstations_v1beta.services.workstations.pagers.ListWorkstationClustersPager: @@ -939,7 +980,7 @@ def create_workstation_cluster( workstation_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 workstation cluster. @@ -1000,8 +1041,10 @@ def sample_create_workstation_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: @@ -1085,7 +1128,7 @@ def update_workstation_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 an existing workstation cluster. @@ -1140,8 +1183,10 @@ def sample_update_workstation_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: @@ -1222,7 +1267,7 @@ def delete_workstation_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 the specified workstation cluster. @@ -1270,8 +1315,10 @@ def sample_delete_workstation_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: @@ -1346,7 +1393,7 @@ def get_workstation_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.WorkstationConfig: r"""Returns the requested workstation configuration. @@ -1390,8 +1437,10 @@ def sample_get_workstation_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.workstations_v1beta.types.WorkstationConfig: @@ -1462,7 +1511,7 @@ def list_workstation_configs( 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.ListWorkstationConfigsPager: r"""Returns all workstation configurations in the specified cluster. @@ -1506,8 +1555,10 @@ def sample_list_workstation_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.workstations_v1beta.services.workstations.pagers.ListWorkstationConfigsPager: @@ -1581,7 +1632,7 @@ def list_usable_workstation_configs( 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.ListUsableWorkstationConfigsPager: r"""Returns all workstation configurations in the specified cluster on which the caller has the @@ -1626,8 +1677,10 @@ def sample_list_usable_workstation_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.workstations_v1beta.services.workstations.pagers.ListUsableWorkstationConfigsPager: @@ -1705,7 +1758,7 @@ def create_workstation_config( workstation_config_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 workstation configuration. @@ -1764,8 +1817,10 @@ def sample_create_workstation_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: @@ -1855,7 +1910,7 @@ def update_workstation_config( 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 an existing workstation configuration. @@ -1908,8 +1963,10 @@ def sample_update_workstation_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: @@ -1998,7 +2055,7 @@ def delete_workstation_config( name: Optional[str] = None, retry: OptionalRetry = gapic_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 workstation configuration. @@ -2046,8 +2103,10 @@ def sample_delete_workstation_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: @@ -2130,7 +2189,7 @@ def get_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.Workstation: r"""Returns the requested workstation. @@ -2173,8 +2232,10 @@ def sample_get_workstation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workstations_v1beta.types.Workstation: @@ -2233,7 +2294,7 @@ def list_workstations( 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.ListWorkstationsPager: r"""Returns all Workstations using the specified workstation configuration. @@ -2276,8 +2337,10 @@ def sample_list_workstations(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workstations_v1beta.services.workstations.pagers.ListWorkstationsPager: @@ -2351,7 +2414,7 @@ def list_usable_workstations( 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.ListUsableWorkstationsPager: r"""Returns all workstations using the specified workstation configuration on which the caller has the @@ -2396,8 +2459,10 @@ def sample_list_usable_workstations(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workstations_v1beta.services.workstations.pagers.ListUsableWorkstationsPager: @@ -2471,7 +2536,7 @@ def create_workstation( workstation_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 workstation. @@ -2530,8 +2595,10 @@ def sample_create_workstation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2606,7 +2673,7 @@ def update_workstation( 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 an existing workstation. @@ -2659,8 +2726,10 @@ def sample_update_workstation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2734,7 +2803,7 @@ def delete_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_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 workstation. @@ -2782,8 +2851,10 @@ def sample_delete_workstation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2853,7 +2924,7 @@ def start_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_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"""Starts running a workstation so that users can connect to it. @@ -2901,8 +2972,10 @@ def sample_start_workstation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -2972,7 +3045,7 @@ def stop_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_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"""Stops running a workstation, reducing costs. @@ -3019,8 +3092,10 @@ def sample_stop_workstation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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: @@ -3090,7 +3165,7 @@ def generate_access_token( workstation: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.GenerateAccessTokenResponse: r"""Returns a short-lived credential that can be used to send authenticated and authorized traffic to a @@ -3137,8 +3212,10 @@ def sample_generate_access_token(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.workstations_v1beta.types.GenerateAccessTokenResponse: @@ -3210,7 +3287,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. @@ -3221,8 +3298,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. @@ -3263,7 +3342,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. @@ -3274,8 +3353,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. @@ -3316,7 +3397,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. @@ -3332,8 +3413,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 """ @@ -3370,7 +3453,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. @@ -3385,8 +3468,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 """ @@ -3423,7 +3508,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. @@ -3436,8 +3521,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. @@ -3542,7 +3629,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. @@ -3556,8 +3643,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. @@ -3662,7 +3751,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. @@ -3677,8 +3766,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-workstations/google/cloud/workstations_v1beta/services/workstations/pagers.py b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/pagers.py index 31116484db45..e6fd0f1f1a9f 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/pagers.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/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 = workstations.ListWorkstationClustersRequest(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 = workstations.ListWorkstationClustersRequest(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 = workstations.ListWorkstationConfigsRequest(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 = workstations.ListWorkstationConfigsRequest(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 = workstations.ListUsableWorkstationConfigsRequest(request) @@ -449,7 +459,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. @@ -463,8 +473,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 = workstations.ListUsableWorkstationConfigsRequest(request) @@ -529,7 +541,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -543,8 +555,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = workstations.ListWorkstationsRequest(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 = workstations.ListWorkstationsRequest(request) @@ -681,7 +697,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -695,8 +711,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = workstations.ListUsableWorkstationsRequest(request) @@ -755,7 +773,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. @@ -769,8 +787,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 = workstations.ListUsableWorkstationsRequest(request) diff --git a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/transports/grpc.py b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/transports/grpc.py index d02a7f3ed2c5..b4b85e238deb 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/transports/grpc.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/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.workstations_v1beta.types import workstations from .base import DEFAULT_CLIENT_INFO, WorkstationsTransport +try: + from google.api_core import client_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.workstations.v1beta.Workstations", + "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.workstations.v1beta.Workstations", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WorkstationsGrpcTransport(WorkstationsTransport): """gRPC backend transport for Workstations. @@ -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_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workstation_cluster" not in self._stubs: - self._stubs["get_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_workstation_cluster"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/GetWorkstationCluster", request_serializer=workstations.GetWorkstationClusterRequest.serialize, response_deserializer=workstations.WorkstationCluster.deserialize, @@ -304,7 +392,7 @@ def list_workstation_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workstation_clusters" not in self._stubs: - self._stubs["list_workstation_clusters"] = self.grpc_channel.unary_unary( + self._stubs["list_workstation_clusters"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/ListWorkstationClusters", request_serializer=workstations.ListWorkstationClustersRequest.serialize, response_deserializer=workstations.ListWorkstationClustersResponse.deserialize, @@ -332,7 +420,9 @@ def create_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workstation_cluster" not in self._stubs: - self._stubs["create_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_workstation_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/CreateWorkstationCluster", request_serializer=workstations.CreateWorkstationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -360,7 +450,9 @@ def update_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workstation_cluster" not in self._stubs: - self._stubs["update_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_workstation_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/UpdateWorkstationCluster", request_serializer=workstations.UpdateWorkstationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -388,7 +480,9 @@ def delete_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workstation_cluster" not in self._stubs: - self._stubs["delete_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_workstation_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/DeleteWorkstationCluster", request_serializer=workstations.DeleteWorkstationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -416,7 +510,7 @@ def get_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workstation_config" not in self._stubs: - self._stubs["get_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["get_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/GetWorkstationConfig", request_serializer=workstations.GetWorkstationConfigRequest.serialize, response_deserializer=workstations.WorkstationConfig.deserialize, @@ -446,7 +540,7 @@ def list_workstation_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workstation_configs" not in self._stubs: - self._stubs["list_workstation_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_workstation_configs"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/ListWorkstationConfigs", request_serializer=workstations.ListWorkstationConfigsRequest.serialize, response_deserializer=workstations.ListWorkstationConfigsResponse.deserialize, @@ -480,7 +574,7 @@ def list_usable_workstation_configs( if "list_usable_workstation_configs" not in self._stubs: self._stubs[ "list_usable_workstation_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/ListUsableWorkstationConfigs", request_serializer=workstations.ListUsableWorkstationConfigsRequest.serialize, response_deserializer=workstations.ListUsableWorkstationConfigsResponse.deserialize, @@ -508,7 +602,7 @@ def create_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workstation_config" not in self._stubs: - self._stubs["create_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["create_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/CreateWorkstationConfig", request_serializer=workstations.CreateWorkstationConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -536,7 +630,7 @@ def update_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workstation_config" not in self._stubs: - self._stubs["update_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["update_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/UpdateWorkstationConfig", request_serializer=workstations.UpdateWorkstationConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -564,7 +658,7 @@ def delete_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workstation_config" not in self._stubs: - self._stubs["delete_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/DeleteWorkstationConfig", request_serializer=workstations.DeleteWorkstationConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -590,7 +684,7 @@ def get_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workstation" not in self._stubs: - self._stubs["get_workstation"] = self.grpc_channel.unary_unary( + self._stubs["get_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/GetWorkstation", request_serializer=workstations.GetWorkstationRequest.serialize, response_deserializer=workstations.Workstation.deserialize, @@ -619,7 +713,7 @@ def list_workstations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workstations" not in self._stubs: - self._stubs["list_workstations"] = self.grpc_channel.unary_unary( + self._stubs["list_workstations"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/ListWorkstations", request_serializer=workstations.ListWorkstationsRequest.serialize, response_deserializer=workstations.ListWorkstationsResponse.deserialize, @@ -650,7 +744,7 @@ def list_usable_workstations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_usable_workstations" not in self._stubs: - self._stubs["list_usable_workstations"] = self.grpc_channel.unary_unary( + self._stubs["list_usable_workstations"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/ListUsableWorkstations", request_serializer=workstations.ListUsableWorkstationsRequest.serialize, response_deserializer=workstations.ListUsableWorkstationsResponse.deserialize, @@ -676,7 +770,7 @@ def create_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workstation" not in self._stubs: - self._stubs["create_workstation"] = self.grpc_channel.unary_unary( + self._stubs["create_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/CreateWorkstation", request_serializer=workstations.CreateWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -702,7 +796,7 @@ def update_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workstation" not in self._stubs: - self._stubs["update_workstation"] = self.grpc_channel.unary_unary( + self._stubs["update_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/UpdateWorkstation", request_serializer=workstations.UpdateWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -728,7 +822,7 @@ def delete_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workstation" not in self._stubs: - self._stubs["delete_workstation"] = self.grpc_channel.unary_unary( + self._stubs["delete_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/DeleteWorkstation", request_serializer=workstations.DeleteWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -755,7 +849,7 @@ def start_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_workstation" not in self._stubs: - self._stubs["start_workstation"] = self.grpc_channel.unary_unary( + self._stubs["start_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/StartWorkstation", request_serializer=workstations.StartWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -781,7 +875,7 @@ def stop_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_workstation" not in self._stubs: - self._stubs["stop_workstation"] = self.grpc_channel.unary_unary( + self._stubs["stop_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/StopWorkstation", request_serializer=workstations.StopWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -812,7 +906,7 @@ def generate_access_token( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_access_token" not in self._stubs: - self._stubs["generate_access_token"] = self.grpc_channel.unary_unary( + self._stubs["generate_access_token"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/GenerateAccessToken", request_serializer=workstations.GenerateAccessTokenRequest.serialize, response_deserializer=workstations.GenerateAccessTokenResponse.deserialize, @@ -820,7 +914,7 @@ def generate_access_token( return self._stubs["generate_access_token"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -832,7 +926,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, @@ -849,7 +943,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, @@ -866,7 +960,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, @@ -885,7 +979,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, @@ -910,7 +1004,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, @@ -936,7 +1030,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, @@ -965,7 +1059,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-workstations/google/cloud/workstations_v1beta/services/workstations/transports/grpc_asyncio.py b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/transports/grpc_asyncio.py index c317f3587fb2..55639e9c605e 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/transports/grpc_asyncio.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/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.workstations_v1beta.types import workstations from .base import DEFAULT_CLIENT_INFO, WorkstationsTransport from .grpc import WorkstationsGrpcTransport +try: + from google.api_core import client_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.workstations.v1beta.Workstations", + "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.workstations.v1beta.Workstations", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WorkstationsGrpcAsyncIOTransport(WorkstationsTransport): """gRPC AsyncIO backend transport for Workstations. @@ -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_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workstation_cluster" not in self._stubs: - self._stubs["get_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_workstation_cluster"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/GetWorkstationCluster", request_serializer=workstations.GetWorkstationClusterRequest.serialize, response_deserializer=workstations.WorkstationCluster.deserialize, @@ -315,7 +400,7 @@ def list_workstation_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workstation_clusters" not in self._stubs: - self._stubs["list_workstation_clusters"] = self.grpc_channel.unary_unary( + self._stubs["list_workstation_clusters"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/ListWorkstationClusters", request_serializer=workstations.ListWorkstationClustersRequest.serialize, response_deserializer=workstations.ListWorkstationClustersResponse.deserialize, @@ -344,7 +429,9 @@ def create_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workstation_cluster" not in self._stubs: - self._stubs["create_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_workstation_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/CreateWorkstationCluster", request_serializer=workstations.CreateWorkstationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -373,7 +460,9 @@ def update_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workstation_cluster" not in self._stubs: - self._stubs["update_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_workstation_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/UpdateWorkstationCluster", request_serializer=workstations.UpdateWorkstationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -402,7 +491,9 @@ def delete_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workstation_cluster" not in self._stubs: - self._stubs["delete_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_workstation_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/DeleteWorkstationCluster", request_serializer=workstations.DeleteWorkstationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -431,7 +522,7 @@ def get_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workstation_config" not in self._stubs: - self._stubs["get_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["get_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/GetWorkstationConfig", request_serializer=workstations.GetWorkstationConfigRequest.serialize, response_deserializer=workstations.WorkstationConfig.deserialize, @@ -461,7 +552,7 @@ def list_workstation_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workstation_configs" not in self._stubs: - self._stubs["list_workstation_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_workstation_configs"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/ListWorkstationConfigs", request_serializer=workstations.ListWorkstationConfigsRequest.serialize, response_deserializer=workstations.ListWorkstationConfigsResponse.deserialize, @@ -495,7 +586,7 @@ def list_usable_workstation_configs( if "list_usable_workstation_configs" not in self._stubs: self._stubs[ "list_usable_workstation_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/ListUsableWorkstationConfigs", request_serializer=workstations.ListUsableWorkstationConfigsRequest.serialize, response_deserializer=workstations.ListUsableWorkstationConfigsResponse.deserialize, @@ -524,7 +615,7 @@ def create_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workstation_config" not in self._stubs: - self._stubs["create_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["create_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/CreateWorkstationConfig", request_serializer=workstations.CreateWorkstationConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -553,7 +644,7 @@ def update_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workstation_config" not in self._stubs: - self._stubs["update_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["update_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/UpdateWorkstationConfig", request_serializer=workstations.UpdateWorkstationConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -582,7 +673,7 @@ def delete_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workstation_config" not in self._stubs: - self._stubs["delete_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/DeleteWorkstationConfig", request_serializer=workstations.DeleteWorkstationConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -610,7 +701,7 @@ def get_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workstation" not in self._stubs: - self._stubs["get_workstation"] = self.grpc_channel.unary_unary( + self._stubs["get_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/GetWorkstation", request_serializer=workstations.GetWorkstationRequest.serialize, response_deserializer=workstations.Workstation.deserialize, @@ -640,7 +731,7 @@ def list_workstations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workstations" not in self._stubs: - self._stubs["list_workstations"] = self.grpc_channel.unary_unary( + self._stubs["list_workstations"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/ListWorkstations", request_serializer=workstations.ListWorkstationsRequest.serialize, response_deserializer=workstations.ListWorkstationsResponse.deserialize, @@ -671,7 +762,7 @@ def list_usable_workstations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_usable_workstations" not in self._stubs: - self._stubs["list_usable_workstations"] = self.grpc_channel.unary_unary( + self._stubs["list_usable_workstations"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/ListUsableWorkstations", request_serializer=workstations.ListUsableWorkstationsRequest.serialize, response_deserializer=workstations.ListUsableWorkstationsResponse.deserialize, @@ -699,7 +790,7 @@ def create_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workstation" not in self._stubs: - self._stubs["create_workstation"] = self.grpc_channel.unary_unary( + self._stubs["create_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/CreateWorkstation", request_serializer=workstations.CreateWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -727,7 +818,7 @@ def update_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workstation" not in self._stubs: - self._stubs["update_workstation"] = self.grpc_channel.unary_unary( + self._stubs["update_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/UpdateWorkstation", request_serializer=workstations.UpdateWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -755,7 +846,7 @@ def delete_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workstation" not in self._stubs: - self._stubs["delete_workstation"] = self.grpc_channel.unary_unary( + self._stubs["delete_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/DeleteWorkstation", request_serializer=workstations.DeleteWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -784,7 +875,7 @@ def start_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_workstation" not in self._stubs: - self._stubs["start_workstation"] = self.grpc_channel.unary_unary( + self._stubs["start_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/StartWorkstation", request_serializer=workstations.StartWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -812,7 +903,7 @@ def stop_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_workstation" not in self._stubs: - self._stubs["stop_workstation"] = self.grpc_channel.unary_unary( + self._stubs["stop_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/StopWorkstation", request_serializer=workstations.StopWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -843,7 +934,7 @@ def generate_access_token( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_access_token" not in self._stubs: - self._stubs["generate_access_token"] = self.grpc_channel.unary_unary( + self._stubs["generate_access_token"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/GenerateAccessToken", request_serializer=workstations.GenerateAccessTokenRequest.serialize, response_deserializer=workstations.GenerateAccessTokenResponse.deserialize, @@ -1077,7 +1168,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: @@ -1093,7 +1184,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, @@ -1110,7 +1201,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, @@ -1127,7 +1218,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, @@ -1146,7 +1237,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, @@ -1171,7 +1262,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, @@ -1197,7 +1288,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, @@ -1226,7 +1317,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-workstations/google/cloud/workstations_v1beta/services/workstations/transports/rest.py b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/transports/rest.py index 7403b20868c9..51f0bc944028 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/transports/rest.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/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, @@ -233,8 +241,10 @@ def post_update_workstation_config(self, response): def pre_create_workstation( self, request: workstations.CreateWorkstationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.CreateWorkstationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.CreateWorkstationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_workstation Override in a subclass to manipulate the request or metadata @@ -256,8 +266,11 @@ def post_create_workstation( def pre_create_workstation_cluster( self, request: workstations.CreateWorkstationClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.CreateWorkstationClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.CreateWorkstationClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_workstation_cluster Override in a subclass to manipulate the request or metadata @@ -279,8 +292,11 @@ def post_create_workstation_cluster( def pre_create_workstation_config( self, request: workstations.CreateWorkstationConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.CreateWorkstationConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.CreateWorkstationConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_workstation_config Override in a subclass to manipulate the request or metadata @@ -302,8 +318,10 @@ def post_create_workstation_config( def pre_delete_workstation( self, request: workstations.DeleteWorkstationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.DeleteWorkstationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.DeleteWorkstationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_workstation Override in a subclass to manipulate the request or metadata @@ -325,8 +343,11 @@ def post_delete_workstation( def pre_delete_workstation_cluster( self, request: workstations.DeleteWorkstationClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.DeleteWorkstationClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.DeleteWorkstationClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_workstation_cluster Override in a subclass to manipulate the request or metadata @@ -348,8 +369,11 @@ def post_delete_workstation_cluster( def pre_delete_workstation_config( self, request: workstations.DeleteWorkstationConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.DeleteWorkstationConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.DeleteWorkstationConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_workstation_config Override in a subclass to manipulate the request or metadata @@ -371,8 +395,10 @@ def post_delete_workstation_config( def pre_generate_access_token( self, request: workstations.GenerateAccessTokenRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.GenerateAccessTokenRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.GenerateAccessTokenRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for generate_access_token Override in a subclass to manipulate the request or metadata @@ -394,8 +420,10 @@ def post_generate_access_token( def pre_get_workstation( self, request: workstations.GetWorkstationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.GetWorkstationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.GetWorkstationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_workstation Override in a subclass to manipulate the request or metadata @@ -417,8 +445,11 @@ def post_get_workstation( def pre_get_workstation_cluster( self, request: workstations.GetWorkstationClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.GetWorkstationClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.GetWorkstationClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_workstation_cluster Override in a subclass to manipulate the request or metadata @@ -440,8 +471,11 @@ def post_get_workstation_cluster( def pre_get_workstation_config( self, request: workstations.GetWorkstationConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.GetWorkstationConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.GetWorkstationConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_workstation_config Override in a subclass to manipulate the request or metadata @@ -463,9 +497,10 @@ def post_get_workstation_config( def pre_list_usable_workstation_configs( self, request: workstations.ListUsableWorkstationConfigsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - workstations.ListUsableWorkstationConfigsRequest, Sequence[Tuple[str, str]] + workstations.ListUsableWorkstationConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_usable_workstation_configs @@ -488,8 +523,11 @@ def post_list_usable_workstation_configs( def pre_list_usable_workstations( self, request: workstations.ListUsableWorkstationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.ListUsableWorkstationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.ListUsableWorkstationsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_usable_workstations Override in a subclass to manipulate the request or metadata @@ -511,8 +549,11 @@ def post_list_usable_workstations( def pre_list_workstation_clusters( self, request: workstations.ListWorkstationClustersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.ListWorkstationClustersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.ListWorkstationClustersRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_workstation_clusters Override in a subclass to manipulate the request or metadata @@ -534,8 +575,11 @@ def post_list_workstation_clusters( def pre_list_workstation_configs( self, request: workstations.ListWorkstationConfigsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.ListWorkstationConfigsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.ListWorkstationConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_workstation_configs Override in a subclass to manipulate the request or metadata @@ -557,8 +601,10 @@ def post_list_workstation_configs( def pre_list_workstations( self, request: workstations.ListWorkstationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.ListWorkstationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.ListWorkstationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_workstations Override in a subclass to manipulate the request or metadata @@ -580,8 +626,10 @@ def post_list_workstations( def pre_start_workstation( self, request: workstations.StartWorkstationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.StartWorkstationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.StartWorkstationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for start_workstation Override in a subclass to manipulate the request or metadata @@ -603,8 +651,10 @@ def post_start_workstation( def pre_stop_workstation( self, request: workstations.StopWorkstationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.StopWorkstationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.StopWorkstationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for stop_workstation Override in a subclass to manipulate the request or metadata @@ -626,8 +676,10 @@ def post_stop_workstation( def pre_update_workstation( self, request: workstations.UpdateWorkstationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.UpdateWorkstationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.UpdateWorkstationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_workstation Override in a subclass to manipulate the request or metadata @@ -649,8 +701,11 @@ def post_update_workstation( def pre_update_workstation_cluster( self, request: workstations.UpdateWorkstationClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.UpdateWorkstationClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.UpdateWorkstationClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_workstation_cluster Override in a subclass to manipulate the request or metadata @@ -672,8 +727,11 @@ def post_update_workstation_cluster( def pre_update_workstation_config( self, request: workstations.UpdateWorkstationConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.UpdateWorkstationConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.UpdateWorkstationConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_workstation_config Override in a subclass to manipulate the request or metadata @@ -695,8 +753,10 @@ def post_update_workstation_config( 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 @@ -716,8 +776,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 @@ -737,8 +799,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 @@ -760,8 +825,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 @@ -781,8 +848,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 @@ -802,8 +871,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 @@ -825,8 +896,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 @@ -1021,7 +1094,7 @@ 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 workstation method over HTTP. @@ -1032,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.Operation: @@ -1046,6 +1121,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseCreateWorkstation._get_http_options() ) + request, metadata = self._interceptor.pre_create_workstation( request, metadata ) @@ -1062,6 +1138,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.CreateWorkstation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "CreateWorkstation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._CreateWorkstation._get_response( self._host, @@ -1081,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_create_workstation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1beta.WorkstationsClient.create_workstation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "CreateWorkstation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateWorkstationCluster( @@ -1120,7 +1245,7 @@ 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 workstation cluster method over HTTP. @@ -1132,8 +1257,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1146,6 +1273,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseCreateWorkstationCluster._get_http_options() ) + request, metadata = self._interceptor.pre_create_workstation_cluster( request, metadata ) @@ -1162,6 +1290,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.CreateWorkstationCluster", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "CreateWorkstationCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( WorkstationsRestTransport._CreateWorkstationCluster._get_response( @@ -1183,7 +1338,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_workstation_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.workstations_v1beta.WorkstationsClient.create_workstation_cluster", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "CreateWorkstationCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateWorkstationConfig( @@ -1222,7 +1399,7 @@ 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 workstation config method over HTTP. @@ -1233,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: ~.operations_pb2.Operation: @@ -1247,6 +1426,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseCreateWorkstationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_workstation_config( request, metadata ) @@ -1263,6 +1443,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.CreateWorkstationConfig", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "CreateWorkstationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._CreateWorkstationConfig._get_response( self._host, @@ -1282,7 +1489,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_workstation_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.workstations_v1beta.WorkstationsClient.create_workstation_config", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "CreateWorkstationConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteWorkstation( @@ -1319,7 +1548,7 @@ 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 workstation method over HTTP. @@ -1330,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: ~.operations_pb2.Operation: @@ -1344,6 +1575,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseDeleteWorkstation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_workstation( request, metadata ) @@ -1356,6 +1588,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.DeleteWorkstation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "DeleteWorkstation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._DeleteWorkstation._get_response( self._host, @@ -1374,7 +1633,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_workstation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1beta.WorkstationsClient.delete_workstation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "DeleteWorkstation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteWorkstationCluster( @@ -1412,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete workstation cluster method over HTTP. @@ -1424,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: ~.operations_pb2.Operation: @@ -1438,6 +1721,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseDeleteWorkstationCluster._get_http_options() ) + request, metadata = self._interceptor.pre_delete_workstation_cluster( request, metadata ) @@ -1450,6 +1734,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.DeleteWorkstationCluster", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "DeleteWorkstationCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( WorkstationsRestTransport._DeleteWorkstationCluster._get_response( @@ -1470,7 +1781,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_workstation_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.workstations_v1beta.WorkstationsClient.delete_workstation_cluster", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "DeleteWorkstationCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteWorkstationConfig( @@ -1508,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete workstation config method over HTTP. @@ -1519,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: ~.operations_pb2.Operation: @@ -1533,6 +1868,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseDeleteWorkstationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_workstation_config( request, metadata ) @@ -1545,6 +1881,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.DeleteWorkstationConfig", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "DeleteWorkstationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._DeleteWorkstationConfig._get_response( self._host, @@ -1563,7 +1926,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_workstation_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.workstations_v1beta.WorkstationsClient.delete_workstation_config", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "DeleteWorkstationConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateAccessToken( @@ -1601,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]]] = (), ) -> workstations.GenerateAccessTokenResponse: r"""Call the generate access token method over HTTP. @@ -1612,8 +1997,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.workstations.GenerateAccessTokenResponse: @@ -1625,6 +2012,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseGenerateAccessToken._get_http_options() ) + request, metadata = self._interceptor.pre_generate_access_token( request, metadata ) @@ -1641,6 +2029,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.GenerateAccessToken", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "GenerateAccessToken", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._GenerateAccessToken._get_response( self._host, @@ -1662,7 +2077,31 @@ def __call__( pb_resp = workstations.GenerateAccessTokenResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_access_token(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workstations.GenerateAccessTokenResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1beta.WorkstationsClient.generate_access_token", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "GenerateAccessToken", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetWorkstation( @@ -1699,7 +2138,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.Workstation: r"""Call the get workstation method over HTTP. @@ -1709,8 +2148,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.workstations.Workstation: @@ -1723,6 +2164,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseGetWorkstation._get_http_options() ) + request, metadata = self._interceptor.pre_get_workstation(request, metadata) transcoded_request = _BaseWorkstationsRestTransport._BaseGetWorkstation._get_transcoded_request( http_options, request @@ -1733,6 +2175,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.GetWorkstation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "GetWorkstation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._GetWorkstation._get_response( self._host, @@ -1753,7 +2222,29 @@ def __call__( pb_resp = workstations.Workstation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_workstation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workstations.Workstation.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1beta.WorkstationsClient.get_workstation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "GetWorkstation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetWorkstationCluster( @@ -1790,7 +2281,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.WorkstationCluster: r"""Call the get workstation cluster method over HTTP. @@ -1801,8 +2292,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.workstations.WorkstationCluster: @@ -1817,6 +2310,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseGetWorkstationCluster._get_http_options() ) + request, metadata = self._interceptor.pre_get_workstation_cluster( request, metadata ) @@ -1829,6 +2323,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.GetWorkstationCluster", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "GetWorkstationCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._GetWorkstationCluster._get_response( self._host, @@ -1849,7 +2370,29 @@ def __call__( pb_resp = workstations.WorkstationCluster.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_workstation_cluster(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workstations.WorkstationCluster.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1beta.WorkstationsClient.get_workstation_cluster", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "GetWorkstationCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetWorkstationConfig( @@ -1886,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]]] = (), ) -> workstations.WorkstationConfig: r"""Call the get workstation config method over HTTP. @@ -1897,8 +2440,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.workstations.WorkstationConfig: @@ -1921,6 +2466,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseGetWorkstationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_workstation_config( request, metadata ) @@ -1933,6 +2479,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.GetWorkstationConfig", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "GetWorkstationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._GetWorkstationConfig._get_response( self._host, @@ -1953,7 +2526,29 @@ def __call__( pb_resp = workstations.WorkstationConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_workstation_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workstations.WorkstationConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1beta.WorkstationsClient.get_workstation_config", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "GetWorkstationConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListUsableWorkstationConfigs( @@ -1991,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]]] = (), ) -> workstations.ListUsableWorkstationConfigsResponse: r"""Call the list usable workstation configs method over HTTP. @@ -2003,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: ~.workstations.ListUsableWorkstationConfigsResponse: @@ -2016,6 +2613,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseListUsableWorkstationConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_usable_workstation_configs( request, metadata ) @@ -2028,6 +2626,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.ListUsableWorkstationConfigs", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "ListUsableWorkstationConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( WorkstationsRestTransport._ListUsableWorkstationConfigs._get_response( @@ -2050,7 +2675,33 @@ def __call__( pb_resp = workstations.ListUsableWorkstationConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_usable_workstation_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + workstations.ListUsableWorkstationConfigsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1beta.WorkstationsClient.list_usable_workstation_configs", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "ListUsableWorkstationConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListUsableWorkstations( @@ -2087,7 +2738,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.ListUsableWorkstationsResponse: r"""Call the list usable workstations method over HTTP. @@ -2098,8 +2749,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.workstations.ListUsableWorkstationsResponse: @@ -2111,6 +2764,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseListUsableWorkstations._get_http_options() ) + request, metadata = self._interceptor.pre_list_usable_workstations( request, metadata ) @@ -2123,6 +2777,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.ListUsableWorkstations", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "ListUsableWorkstations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._ListUsableWorkstations._get_response( self._host, @@ -2143,7 +2824,31 @@ def __call__( pb_resp = workstations.ListUsableWorkstationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_usable_workstations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + workstations.ListUsableWorkstationsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1beta.WorkstationsClient.list_usable_workstations", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "ListUsableWorkstations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListWorkstationClusters( @@ -2181,7 +2886,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.ListWorkstationClustersResponse: r"""Call the list workstation clusters method over HTTP. @@ -2192,8 +2897,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.workstations.ListWorkstationClustersResponse: @@ -2205,6 +2912,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseListWorkstationClusters._get_http_options() ) + request, metadata = self._interceptor.pre_list_workstation_clusters( request, metadata ) @@ -2217,6 +2925,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.ListWorkstationClusters", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "ListWorkstationClusters", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._ListWorkstationClusters._get_response( self._host, @@ -2237,7 +2972,31 @@ def __call__( pb_resp = workstations.ListWorkstationClustersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_workstation_clusters(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + workstations.ListWorkstationClustersResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1beta.WorkstationsClient.list_workstation_clusters", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "ListWorkstationClusters", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListWorkstationConfigs( @@ -2274,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]]] = (), ) -> workstations.ListWorkstationConfigsResponse: r"""Call the list workstation configs method over HTTP. @@ -2285,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: ~.workstations.ListWorkstationConfigsResponse: @@ -2298,6 +3059,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseListWorkstationConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_workstation_configs( request, metadata ) @@ -2310,6 +3072,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.ListWorkstationConfigs", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "ListWorkstationConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._ListWorkstationConfigs._get_response( self._host, @@ -2330,7 +3119,31 @@ def __call__( pb_resp = workstations.ListWorkstationConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_workstation_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + workstations.ListWorkstationConfigsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1beta.WorkstationsClient.list_workstation_configs", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "ListWorkstationConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListWorkstations( @@ -2367,7 +3180,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.ListWorkstationsResponse: r"""Call the list workstations method over HTTP. @@ -2377,8 +3190,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.workstations.ListWorkstationsResponse: @@ -2390,6 +3205,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseListWorkstations._get_http_options() ) + request, metadata = self._interceptor.pre_list_workstations( request, metadata ) @@ -2402,6 +3218,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.ListWorkstations", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "ListWorkstations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._ListWorkstations._get_response( self._host, @@ -2422,7 +3265,31 @@ def __call__( pb_resp = workstations.ListWorkstationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_workstations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workstations.ListWorkstationsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1beta.WorkstationsClient.list_workstations", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "ListWorkstations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StartWorkstation( @@ -2460,7 +3327,7 @@ 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 start workstation method over HTTP. @@ -2470,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: ~.operations_pb2.Operation: @@ -2484,6 +3353,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseStartWorkstation._get_http_options() ) + request, metadata = self._interceptor.pre_start_workstation( request, metadata ) @@ -2500,6 +3370,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.StartWorkstation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "StartWorkstation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._StartWorkstation._get_response( self._host, @@ -2519,7 +3416,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_start_workstation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1beta.WorkstationsClient.start_workstation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "StartWorkstation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StopWorkstation( @@ -2557,7 +3476,7 @@ 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 stop workstation method over HTTP. @@ -2567,8 +3486,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2581,6 +3502,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseStopWorkstation._get_http_options() ) + request, metadata = self._interceptor.pre_stop_workstation( request, metadata ) @@ -2597,6 +3519,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.StopWorkstation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "StopWorkstation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._StopWorkstation._get_response( self._host, @@ -2616,7 +3565,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_stop_workstation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1beta.WorkstationsClient.stop_workstation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "StopWorkstation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateWorkstation( @@ -2654,7 +3625,7 @@ 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 workstation method over HTTP. @@ -2665,8 +3636,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2679,6 +3652,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseUpdateWorkstation._get_http_options() ) + request, metadata = self._interceptor.pre_update_workstation( request, metadata ) @@ -2695,6 +3669,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.UpdateWorkstation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "UpdateWorkstation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._UpdateWorkstation._get_response( self._host, @@ -2714,7 +3715,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_workstation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.workstations_v1beta.WorkstationsClient.update_workstation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "UpdateWorkstation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateWorkstationCluster( @@ -2753,7 +3776,7 @@ 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 workstation cluster method over HTTP. @@ -2765,8 +3788,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2779,6 +3804,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseUpdateWorkstationCluster._get_http_options() ) + request, metadata = self._interceptor.pre_update_workstation_cluster( request, metadata ) @@ -2795,6 +3821,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.UpdateWorkstationCluster", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "UpdateWorkstationCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( WorkstationsRestTransport._UpdateWorkstationCluster._get_response( @@ -2816,7 +3869,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_workstation_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.workstations_v1beta.WorkstationsClient.update_workstation_cluster", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "UpdateWorkstationCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateWorkstationConfig( @@ -2855,7 +3930,7 @@ 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 workstation config method over HTTP. @@ -2866,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: ~.operations_pb2.Operation: @@ -2880,6 +3957,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseUpdateWorkstationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_workstation_config( request, metadata ) @@ -2896,6 +3974,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.UpdateWorkstationConfig", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "UpdateWorkstationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._UpdateWorkstationConfig._get_response( self._host, @@ -2915,7 +4020,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_workstation_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.workstations_v1beta.WorkstationsClient.update_workstation_config", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "UpdateWorkstationConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -3149,7 +4276,7 @@ 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. @@ -3159,8 +4286,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -3169,6 +4298,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseWorkstationsRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -3181,6 +4311,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._GetIamPolicy._get_response( self._host, @@ -3200,6 +4357,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.workstations_v1beta.WorkstationsAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3241,7 +4419,7 @@ 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. @@ -3251,8 +4429,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -3261,6 +4441,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseWorkstationsRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -3279,6 +4460,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._SetIamPolicy._get_response( self._host, @@ -3299,6 +4507,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.workstations_v1beta.WorkstationsAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3340,7 +4569,7 @@ 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. @@ -3350,8 +4579,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -3360,6 +4591,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -3376,6 +4608,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._TestIamPermissions._get_response( self._host, @@ -3396,6 +4655,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.workstations_v1beta.WorkstationsAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3437,7 +4717,7 @@ 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. @@ -3447,13 +4727,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 = ( _BaseWorkstationsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -3470,6 +4753,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._CancelOperation._get_response( self._host, @@ -3526,7 +4836,7 @@ 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. @@ -3536,13 +4846,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 = ( _BaseWorkstationsRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -3555,6 +4868,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._DeleteOperation._get_response( self._host, @@ -3610,7 +4950,7 @@ 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. @@ -3620,8 +4960,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -3630,6 +4972,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseWorkstationsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -3642,6 +4985,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.GetOperation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._GetOperation._get_response( self._host, @@ -3661,6 +5031,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.workstations_v1beta.WorkstationsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3701,7 +5092,7 @@ 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. @@ -3711,8 +5102,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -3721,6 +5114,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseWorkstationsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -3731,6 +5125,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.workstations_v1beta.WorkstationsClient.ListOperations", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._ListOperations._get_response( self._host, @@ -3750,6 +5171,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.workstations_v1beta.WorkstationsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-workstations/samples/generated_samples/snippet_metadata_google.cloud.workstations.v1.json b/packages/google-cloud-workstations/samples/generated_samples/snippet_metadata_google.cloud.workstations.v1.json index e24bb9d99fba..c9f644c1d20c 100644 --- a/packages/google-cloud-workstations/samples/generated_samples/snippet_metadata_google.cloud.workstations.v1.json +++ b/packages/google-cloud-workstations/samples/generated_samples/snippet_metadata_google.cloud.workstations.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-workstations", - "version": "0.5.10" + "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", @@ -409,7 +409,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -497,7 +497,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -578,7 +578,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -658,7 +658,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -739,7 +739,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -819,7 +819,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -900,7 +900,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -980,7 +980,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1061,7 +1061,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.types.GenerateAccessTokenResponse", @@ -1141,7 +1141,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.types.GenerateAccessTokenResponse", @@ -1222,7 +1222,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.types.WorkstationCluster", @@ -1302,7 +1302,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.types.WorkstationCluster", @@ -1383,7 +1383,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.types.WorkstationConfig", @@ -1463,7 +1463,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.types.WorkstationConfig", @@ -1544,7 +1544,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.types.Workstation", @@ -1624,7 +1624,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.types.Workstation", @@ -1705,7 +1705,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.services.workstations.pagers.ListUsableWorkstationConfigsAsyncPager", @@ -1785,7 +1785,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.services.workstations.pagers.ListUsableWorkstationConfigsPager", @@ -1866,7 +1866,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.services.workstations.pagers.ListUsableWorkstationsAsyncPager", @@ -1946,7 +1946,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.services.workstations.pagers.ListUsableWorkstationsPager", @@ -2027,7 +2027,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.services.workstations.pagers.ListWorkstationClustersAsyncPager", @@ -2107,7 +2107,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.services.workstations.pagers.ListWorkstationClustersPager", @@ -2188,7 +2188,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.services.workstations.pagers.ListWorkstationConfigsAsyncPager", @@ -2268,7 +2268,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.services.workstations.pagers.ListWorkstationConfigsPager", @@ -2349,7 +2349,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.services.workstations.pagers.ListWorkstationsAsyncPager", @@ -2429,7 +2429,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.services.workstations.pagers.ListWorkstationsPager", @@ -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", @@ -2671,7 +2671,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2751,7 +2751,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2836,7 +2836,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2920,7 +2920,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3005,7 +3005,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3089,7 +3089,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3174,7 +3174,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3258,7 +3258,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-workstations/samples/generated_samples/snippet_metadata_google.cloud.workstations.v1beta.json b/packages/google-cloud-workstations/samples/generated_samples/snippet_metadata_google.cloud.workstations.v1beta.json index 188bb17930e6..2a6523f2cb2d 100644 --- a/packages/google-cloud-workstations/samples/generated_samples/snippet_metadata_google.cloud.workstations.v1beta.json +++ b/packages/google-cloud-workstations/samples/generated_samples/snippet_metadata_google.cloud.workstations.v1beta.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-workstations", - "version": "0.5.10" + "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", @@ -409,7 +409,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -497,7 +497,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -578,7 +578,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -658,7 +658,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -739,7 +739,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -819,7 +819,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -900,7 +900,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -980,7 +980,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1061,7 +1061,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.types.GenerateAccessTokenResponse", @@ -1141,7 +1141,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.types.GenerateAccessTokenResponse", @@ -1222,7 +1222,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.types.WorkstationCluster", @@ -1302,7 +1302,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.types.WorkstationCluster", @@ -1383,7 +1383,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.types.WorkstationConfig", @@ -1463,7 +1463,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.types.WorkstationConfig", @@ -1544,7 +1544,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.types.Workstation", @@ -1624,7 +1624,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.types.Workstation", @@ -1705,7 +1705,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.services.workstations.pagers.ListUsableWorkstationConfigsAsyncPager", @@ -1785,7 +1785,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.services.workstations.pagers.ListUsableWorkstationConfigsPager", @@ -1866,7 +1866,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.services.workstations.pagers.ListUsableWorkstationsAsyncPager", @@ -1946,7 +1946,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.services.workstations.pagers.ListUsableWorkstationsPager", @@ -2027,7 +2027,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.services.workstations.pagers.ListWorkstationClustersAsyncPager", @@ -2107,7 +2107,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.services.workstations.pagers.ListWorkstationClustersPager", @@ -2188,7 +2188,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.services.workstations.pagers.ListWorkstationConfigsAsyncPager", @@ -2268,7 +2268,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.services.workstations.pagers.ListWorkstationConfigsPager", @@ -2349,7 +2349,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.services.workstations.pagers.ListWorkstationsAsyncPager", @@ -2429,7 +2429,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.services.workstations.pagers.ListWorkstationsPager", @@ -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", @@ -2671,7 +2671,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2751,7 +2751,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2836,7 +2836,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2920,7 +2920,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3005,7 +3005,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3089,7 +3089,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3174,7 +3174,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3258,7 +3258,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-workstations/tests/unit/gapic/workstations_v1/test_workstations.py b/packages/google-cloud-workstations/tests/unit/gapic/workstations_v1/test_workstations.py index ec343d91d017..2b5a25716e75 100644 --- a/packages/google-cloud-workstations/tests/unit/gapic/workstations_v1/test_workstations.py +++ b/packages/google-cloud-workstations/tests/unit/gapic/workstations_v1/test_workstations.py @@ -9237,6 +9237,7 @@ def test_get_workstation_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_workstation_cluster(request) @@ -9284,6 +9285,7 @@ def test_get_workstation_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_workstation_cluster(**mock_args) @@ -9427,6 +9429,7 @@ def test_list_workstation_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_workstation_clusters(request) @@ -9480,6 +9483,7 @@ def test_list_workstation_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_workstation_clusters(**mock_args) @@ -9698,6 +9702,7 @@ def test_create_workstation_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_workstation_cluster(request) @@ -9763,6 +9768,7 @@ def test_create_workstation_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_workstation_cluster(**mock_args) @@ -9906,6 +9912,7 @@ def test_update_workstation_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_workstation_cluster(request) @@ -9968,6 +9975,7 @@ def test_update_workstation_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_workstation_cluster(**mock_args) @@ -10114,6 +10122,7 @@ def test_delete_workstation_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_workstation_cluster(request) @@ -10168,6 +10177,7 @@ def test_delete_workstation_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_workstation_cluster(**mock_args) @@ -10304,6 +10314,7 @@ def test_get_workstation_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_workstation_config(request) @@ -10351,6 +10362,7 @@ def test_get_workstation_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_workstation_config(**mock_args) @@ -10494,6 +10506,7 @@ def test_list_workstation_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_workstation_configs(request) @@ -10549,6 +10562,7 @@ def test_list_workstation_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_workstation_configs(**mock_args) @@ -10759,6 +10773,7 @@ def test_list_usable_workstation_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_usable_workstation_configs(request) @@ -10818,6 +10833,7 @@ def test_list_usable_workstation_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_usable_workstation_configs(**mock_args) @@ -11041,6 +11057,7 @@ def test_create_workstation_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_workstation_config(request) @@ -11108,6 +11125,7 @@ def test_create_workstation_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_workstation_config(**mock_args) @@ -11251,6 +11269,7 @@ def test_update_workstation_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_workstation_config(request) @@ -11313,6 +11332,7 @@ def test_update_workstation_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_workstation_config(**mock_args) @@ -11459,6 +11479,7 @@ def test_delete_workstation_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_workstation_config(request) @@ -11513,6 +11534,7 @@ def test_delete_workstation_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_workstation_config(**mock_args) @@ -11644,6 +11666,7 @@ def test_get_workstation_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_workstation(request) @@ -11691,6 +11714,7 @@ def test_get_workstation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workstation(**mock_args) @@ -11831,6 +11855,7 @@ def test_list_workstations_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_workstations(request) @@ -11886,6 +11911,7 @@ def test_list_workstations_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workstations(**mock_args) @@ -12094,6 +12120,7 @@ def test_list_usable_workstations_rest_required_fields( response_value._content = json_return_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_workstations(request) @@ -12149,6 +12176,7 @@ def test_list_usable_workstations_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workstations(**mock_args) @@ -12365,6 +12393,7 @@ def test_create_workstation_rest_required_fields( response_value._content = json_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_workstation(request) @@ -12432,6 +12461,7 @@ def test_create_workstation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workstation(**mock_args) @@ -12574,6 +12604,7 @@ def test_update_workstation_rest_required_fields( response_value._content = json_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_workstation(request) @@ -12636,6 +12667,7 @@ def test_update_workstation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workstation(**mock_args) @@ -12780,6 +12812,7 @@ def test_delete_workstation_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_workstation(request) @@ -12833,6 +12866,7 @@ def test_delete_workstation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workstation(**mock_args) @@ -12968,6 +13002,7 @@ def test_start_workstation_rest_required_fields( response_value._content = json_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_workstation(request) @@ -13013,6 +13048,7 @@ def test_start_workstation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workstation(**mock_args) @@ -13148,6 +13184,7 @@ def test_stop_workstation_rest_required_fields( response_value._content = json_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_workstation(request) @@ -13193,6 +13230,7 @@ def test_stop_workstation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workstation(**mock_args) @@ -13330,6 +13368,7 @@ def test_generate_access_token_rest_required_fields( response_value._content = json_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_access_token(request) @@ -13377,6 +13416,7 @@ def test_generate_access_token_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_access_token(**mock_args) @@ -14591,6 +14631,7 @@ def test_get_workstation_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_workstation_cluster(request) @@ -14636,6 +14677,7 @@ def test_get_workstation_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_workstation_cluster(request) # Establish that the response is the type that we expect. @@ -14684,6 +14726,7 @@ def test_get_workstation_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 = workstations.WorkstationCluster.to_json( workstations.WorkstationCluster() ) @@ -14730,6 +14773,7 @@ def test_list_workstation_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_workstation_clusters(request) @@ -14766,6 +14810,7 @@ def test_list_workstation_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_workstation_clusters(request) # Establish that the response is the type that we expect. @@ -14807,6 +14852,7 @@ def test_list_workstation_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 = workstations.ListWorkstationClustersResponse.to_json( workstations.ListWorkstationClustersResponse() ) @@ -14853,6 +14899,7 @@ def test_create_workstation_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_workstation_cluster(request) @@ -14986,6 +15033,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_workstation_cluster(request) # Establish that the response is the type that we expect. @@ -15027,6 +15075,7 @@ def test_create_workstation_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 @@ -15075,6 +15124,7 @@ def test_update_workstation_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_workstation_cluster(request) @@ -15212,6 +15262,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_workstation_cluster(request) # Establish that the response is the type that we expect. @@ -15253,6 +15304,7 @@ def test_update_workstation_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 @@ -15299,6 +15351,7 @@ def test_delete_workstation_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_workstation_cluster(request) @@ -15331,6 +15384,7 @@ def test_delete_workstation_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_workstation_cluster(request) # Establish that the response is the type that we expect. @@ -15372,6 +15426,7 @@ def test_delete_workstation_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 @@ -15418,6 +15473,7 @@ def test_get_workstation_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_workstation_config(request) @@ -15461,6 +15517,7 @@ def test_get_workstation_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_workstation_config(request) # Establish that the response is the type that we expect. @@ -15507,6 +15564,7 @@ def test_get_workstation_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 = workstations.WorkstationConfig.to_json( workstations.WorkstationConfig() ) @@ -15555,6 +15613,7 @@ def test_list_workstation_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_workstation_configs(request) @@ -15593,6 +15652,7 @@ def test_list_workstation_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_workstation_configs(request) # Establish that the response is the type that we expect. @@ -15634,6 +15694,7 @@ def test_list_workstation_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 = workstations.ListWorkstationConfigsResponse.to_json( workstations.ListWorkstationConfigsResponse() ) @@ -15682,6 +15743,7 @@ def test_list_usable_workstation_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_usable_workstation_configs(request) @@ -15722,6 +15784,7 @@ def test_list_usable_workstation_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_usable_workstation_configs(request) # Establish that the response is the type that we expect. @@ -15763,6 +15826,7 @@ def test_list_usable_workstation_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 = workstations.ListUsableWorkstationConfigsResponse.to_json( workstations.ListUsableWorkstationConfigsResponse() ) @@ -15811,6 +15875,7 @@ def test_create_workstation_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_workstation_config(request) @@ -15987,6 +16052,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_workstation_config(request) # Establish that the response is the type that we expect. @@ -16028,6 +16094,7 @@ def test_create_workstation_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 @@ -16076,6 +16143,7 @@ def test_update_workstation_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_workstation_config(request) @@ -16254,6 +16322,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_workstation_config(request) # Establish that the response is the type that we expect. @@ -16295,6 +16364,7 @@ def test_update_workstation_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 @@ -16341,6 +16411,7 @@ def test_delete_workstation_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_workstation_config(request) @@ -16373,6 +16444,7 @@ def test_delete_workstation_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_workstation_config(request) # Establish that the response is the type that we expect. @@ -16414,6 +16486,7 @@ def test_delete_workstation_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 @@ -16460,6 +16533,7 @@ def test_get_workstation_rest_bad_request( response_value.status_code = 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_workstation(request) @@ -16503,6 +16577,7 @@ def test_get_workstation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_workstation(request) # Establish that the response is the type that we expect. @@ -16549,6 +16624,7 @@ def test_get_workstation_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = workstations.Workstation.to_json(workstations.Workstation()) req.return_value.content = return_value @@ -16595,6 +16671,7 @@ def test_list_workstations_rest_bad_request( response_value.status_code = 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_workstations(request) @@ -16633,6 +16710,7 @@ def test_list_workstations_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_workstations(request) # Establish that the response is the type that we expect. @@ -16674,6 +16752,7 @@ def test_list_workstations_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = workstations.ListWorkstationsResponse.to_json( workstations.ListWorkstationsResponse() ) @@ -16722,6 +16801,7 @@ def test_list_usable_workstations_rest_bad_request( response_value.status_code = 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_workstations(request) @@ -16760,6 +16840,7 @@ def test_list_usable_workstations_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_workstations(request) # Establish that the response is the type that we expect. @@ -16801,6 +16882,7 @@ def test_list_usable_workstations_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = workstations.ListUsableWorkstationsResponse.to_json( workstations.ListUsableWorkstationsResponse() ) @@ -16849,6 +16931,7 @@ def test_create_workstation_rest_bad_request( response_value.status_code = 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_workstation(request) @@ -16963,6 +17046,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_workstation(request) # Establish that the response is the type that we expect. @@ -17004,6 +17088,7 @@ def test_create_workstation_rest_interceptors(null_interceptor): req.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 @@ -17052,6 +17137,7 @@ def test_update_workstation_rest_bad_request( response_value.status_code = 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_workstation(request) @@ -17168,6 +17254,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_workstation(request) # Establish that the response is the type that we expect. @@ -17209,6 +17296,7 @@ def test_update_workstation_rest_interceptors(null_interceptor): req.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 @@ -17255,6 +17343,7 @@ def test_delete_workstation_rest_bad_request( response_value.status_code = 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_workstation(request) @@ -17287,6 +17376,7 @@ def test_delete_workstation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_workstation(request) # Establish that the response is the type that we expect. @@ -17328,6 +17418,7 @@ def test_delete_workstation_rest_interceptors(null_interceptor): req.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 @@ -17374,6 +17465,7 @@ def test_start_workstation_rest_bad_request( response_value.status_code = 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_workstation(request) @@ -17406,6 +17498,7 @@ def test_start_workstation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_workstation(request) # Establish that the response is the type that we expect. @@ -17447,6 +17540,7 @@ def test_start_workstation_rest_interceptors(null_interceptor): req.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 @@ -17493,6 +17587,7 @@ def test_stop_workstation_rest_bad_request( response_value.status_code = 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_workstation(request) @@ -17525,6 +17620,7 @@ def test_stop_workstation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_workstation(request) # Establish that the response is the type that we expect. @@ -17566,6 +17662,7 @@ def test_stop_workstation_rest_interceptors(null_interceptor): req.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 @@ -17612,6 +17709,7 @@ def test_generate_access_token_rest_bad_request( response_value.status_code = 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_access_token(request) @@ -17649,6 +17747,7 @@ def test_generate_access_token_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_access_token(request) # Establish that the response is the type that we expect. @@ -17689,6 +17788,7 @@ def test_generate_access_token_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = workstations.GenerateAccessTokenResponse.to_json( workstations.GenerateAccessTokenResponse() ) @@ -17740,6 +17840,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) @@ -17772,6 +17873,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) @@ -17805,6 +17907,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) @@ -17837,6 +17940,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) @@ -17870,6 +17974,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) @@ -17902,6 +18007,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) @@ -17932,6 +18038,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) @@ -17962,6 +18069,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) @@ -17992,6 +18100,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) @@ -18022,6 +18131,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) @@ -18052,6 +18162,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) @@ -18082,6 +18193,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) @@ -18112,6 +18224,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) @@ -18142,6 +18255,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-workstations/tests/unit/gapic/workstations_v1beta/test_workstations.py b/packages/google-cloud-workstations/tests/unit/gapic/workstations_v1beta/test_workstations.py index b8a654e1e52d..645615e933de 100644 --- a/packages/google-cloud-workstations/tests/unit/gapic/workstations_v1beta/test_workstations.py +++ b/packages/google-cloud-workstations/tests/unit/gapic/workstations_v1beta/test_workstations.py @@ -9241,6 +9241,7 @@ def test_get_workstation_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_workstation_cluster(request) @@ -9288,6 +9289,7 @@ def test_get_workstation_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_workstation_cluster(**mock_args) @@ -9431,6 +9433,7 @@ def test_list_workstation_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_workstation_clusters(request) @@ -9484,6 +9487,7 @@ def test_list_workstation_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_workstation_clusters(**mock_args) @@ -9702,6 +9706,7 @@ def test_create_workstation_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_workstation_cluster(request) @@ -9767,6 +9772,7 @@ def test_create_workstation_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_workstation_cluster(**mock_args) @@ -9910,6 +9916,7 @@ def test_update_workstation_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_workstation_cluster(request) @@ -9972,6 +9979,7 @@ def test_update_workstation_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_workstation_cluster(**mock_args) @@ -10118,6 +10126,7 @@ def test_delete_workstation_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_workstation_cluster(request) @@ -10172,6 +10181,7 @@ def test_delete_workstation_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_workstation_cluster(**mock_args) @@ -10308,6 +10318,7 @@ def test_get_workstation_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_workstation_config(request) @@ -10355,6 +10366,7 @@ def test_get_workstation_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_workstation_config(**mock_args) @@ -10498,6 +10510,7 @@ def test_list_workstation_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_workstation_configs(request) @@ -10553,6 +10566,7 @@ def test_list_workstation_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_workstation_configs(**mock_args) @@ -10763,6 +10777,7 @@ def test_list_usable_workstation_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_usable_workstation_configs(request) @@ -10822,6 +10837,7 @@ def test_list_usable_workstation_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_usable_workstation_configs(**mock_args) @@ -11045,6 +11061,7 @@ def test_create_workstation_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_workstation_config(request) @@ -11112,6 +11129,7 @@ def test_create_workstation_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_workstation_config(**mock_args) @@ -11255,6 +11273,7 @@ def test_update_workstation_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_workstation_config(request) @@ -11317,6 +11336,7 @@ def test_update_workstation_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_workstation_config(**mock_args) @@ -11463,6 +11483,7 @@ def test_delete_workstation_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_workstation_config(request) @@ -11517,6 +11538,7 @@ def test_delete_workstation_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_workstation_config(**mock_args) @@ -11648,6 +11670,7 @@ def test_get_workstation_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_workstation(request) @@ -11695,6 +11718,7 @@ def test_get_workstation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workstation(**mock_args) @@ -11835,6 +11859,7 @@ def test_list_workstations_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_workstations(request) @@ -11890,6 +11915,7 @@ def test_list_workstations_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workstations(**mock_args) @@ -12098,6 +12124,7 @@ def test_list_usable_workstations_rest_required_fields( response_value._content = json_return_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_workstations(request) @@ -12153,6 +12180,7 @@ def test_list_usable_workstations_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workstations(**mock_args) @@ -12369,6 +12397,7 @@ def test_create_workstation_rest_required_fields( response_value._content = json_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_workstation(request) @@ -12436,6 +12465,7 @@ def test_create_workstation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workstation(**mock_args) @@ -12578,6 +12608,7 @@ def test_update_workstation_rest_required_fields( response_value._content = json_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_workstation(request) @@ -12640,6 +12671,7 @@ def test_update_workstation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workstation(**mock_args) @@ -12784,6 +12816,7 @@ def test_delete_workstation_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_workstation(request) @@ -12837,6 +12870,7 @@ def test_delete_workstation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workstation(**mock_args) @@ -12972,6 +13006,7 @@ def test_start_workstation_rest_required_fields( response_value._content = json_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_workstation(request) @@ -13017,6 +13052,7 @@ def test_start_workstation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workstation(**mock_args) @@ -13152,6 +13188,7 @@ def test_stop_workstation_rest_required_fields( response_value._content = json_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_workstation(request) @@ -13197,6 +13234,7 @@ def test_stop_workstation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workstation(**mock_args) @@ -13334,6 +13372,7 @@ def test_generate_access_token_rest_required_fields( response_value._content = json_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_access_token(request) @@ -13381,6 +13420,7 @@ def test_generate_access_token_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_access_token(**mock_args) @@ -14596,6 +14636,7 @@ def test_get_workstation_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_workstation_cluster(request) @@ -14641,6 +14682,7 @@ def test_get_workstation_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_workstation_cluster(request) # Establish that the response is the type that we expect. @@ -14689,6 +14731,7 @@ def test_get_workstation_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 = workstations.WorkstationCluster.to_json( workstations.WorkstationCluster() ) @@ -14735,6 +14778,7 @@ def test_list_workstation_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_workstation_clusters(request) @@ -14771,6 +14815,7 @@ def test_list_workstation_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_workstation_clusters(request) # Establish that the response is the type that we expect. @@ -14812,6 +14857,7 @@ def test_list_workstation_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 = workstations.ListWorkstationClustersResponse.to_json( workstations.ListWorkstationClustersResponse() ) @@ -14858,6 +14904,7 @@ def test_create_workstation_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_workstation_cluster(request) @@ -14991,6 +15038,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_workstation_cluster(request) # Establish that the response is the type that we expect. @@ -15032,6 +15080,7 @@ def test_create_workstation_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 @@ -15080,6 +15129,7 @@ def test_update_workstation_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_workstation_cluster(request) @@ -15217,6 +15267,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_workstation_cluster(request) # Establish that the response is the type that we expect. @@ -15258,6 +15309,7 @@ def test_update_workstation_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 @@ -15304,6 +15356,7 @@ def test_delete_workstation_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_workstation_cluster(request) @@ -15336,6 +15389,7 @@ def test_delete_workstation_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_workstation_cluster(request) # Establish that the response is the type that we expect. @@ -15377,6 +15431,7 @@ def test_delete_workstation_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 @@ -15423,6 +15478,7 @@ def test_get_workstation_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_workstation_config(request) @@ -15467,6 +15523,7 @@ def test_get_workstation_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_workstation_config(request) # Establish that the response is the type that we expect. @@ -15514,6 +15571,7 @@ def test_get_workstation_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 = workstations.WorkstationConfig.to_json( workstations.WorkstationConfig() ) @@ -15562,6 +15620,7 @@ def test_list_workstation_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_workstation_configs(request) @@ -15600,6 +15659,7 @@ def test_list_workstation_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_workstation_configs(request) # Establish that the response is the type that we expect. @@ -15641,6 +15701,7 @@ def test_list_workstation_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 = workstations.ListWorkstationConfigsResponse.to_json( workstations.ListWorkstationConfigsResponse() ) @@ -15689,6 +15750,7 @@ def test_list_usable_workstation_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_usable_workstation_configs(request) @@ -15729,6 +15791,7 @@ def test_list_usable_workstation_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_usable_workstation_configs(request) # Establish that the response is the type that we expect. @@ -15770,6 +15833,7 @@ def test_list_usable_workstation_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 = workstations.ListUsableWorkstationConfigsResponse.to_json( workstations.ListUsableWorkstationConfigsResponse() ) @@ -15818,6 +15882,7 @@ def test_create_workstation_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_workstation_config(request) @@ -16007,6 +16072,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_workstation_config(request) # Establish that the response is the type that we expect. @@ -16048,6 +16114,7 @@ def test_create_workstation_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 @@ -16096,6 +16163,7 @@ def test_update_workstation_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_workstation_config(request) @@ -16287,6 +16355,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_workstation_config(request) # Establish that the response is the type that we expect. @@ -16328,6 +16397,7 @@ def test_update_workstation_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 @@ -16374,6 +16444,7 @@ def test_delete_workstation_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_workstation_config(request) @@ -16406,6 +16477,7 @@ def test_delete_workstation_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_workstation_config(request) # Establish that the response is the type that we expect. @@ -16447,6 +16519,7 @@ def test_delete_workstation_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 @@ -16493,6 +16566,7 @@ def test_get_workstation_rest_bad_request( response_value.status_code = 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_workstation(request) @@ -16536,6 +16610,7 @@ def test_get_workstation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_workstation(request) # Establish that the response is the type that we expect. @@ -16582,6 +16657,7 @@ def test_get_workstation_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = workstations.Workstation.to_json(workstations.Workstation()) req.return_value.content = return_value @@ -16628,6 +16704,7 @@ def test_list_workstations_rest_bad_request( response_value.status_code = 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_workstations(request) @@ -16666,6 +16743,7 @@ def test_list_workstations_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_workstations(request) # Establish that the response is the type that we expect. @@ -16707,6 +16785,7 @@ def test_list_workstations_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = workstations.ListWorkstationsResponse.to_json( workstations.ListWorkstationsResponse() ) @@ -16755,6 +16834,7 @@ def test_list_usable_workstations_rest_bad_request( response_value.status_code = 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_workstations(request) @@ -16793,6 +16873,7 @@ def test_list_usable_workstations_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_workstations(request) # Establish that the response is the type that we expect. @@ -16834,6 +16915,7 @@ def test_list_usable_workstations_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = workstations.ListUsableWorkstationsResponse.to_json( workstations.ListUsableWorkstationsResponse() ) @@ -16882,6 +16964,7 @@ def test_create_workstation_rest_bad_request( response_value.status_code = 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_workstation(request) @@ -16997,6 +17080,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_workstation(request) # Establish that the response is the type that we expect. @@ -17038,6 +17122,7 @@ def test_create_workstation_rest_interceptors(null_interceptor): req.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 @@ -17086,6 +17171,7 @@ def test_update_workstation_rest_bad_request( response_value.status_code = 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_workstation(request) @@ -17203,6 +17289,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_workstation(request) # Establish that the response is the type that we expect. @@ -17244,6 +17331,7 @@ def test_update_workstation_rest_interceptors(null_interceptor): req.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 @@ -17290,6 +17378,7 @@ def test_delete_workstation_rest_bad_request( response_value.status_code = 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_workstation(request) @@ -17322,6 +17411,7 @@ def test_delete_workstation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_workstation(request) # Establish that the response is the type that we expect. @@ -17363,6 +17453,7 @@ def test_delete_workstation_rest_interceptors(null_interceptor): req.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 @@ -17409,6 +17500,7 @@ def test_start_workstation_rest_bad_request( response_value.status_code = 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_workstation(request) @@ -17441,6 +17533,7 @@ def test_start_workstation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_workstation(request) # Establish that the response is the type that we expect. @@ -17482,6 +17575,7 @@ def test_start_workstation_rest_interceptors(null_interceptor): req.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 @@ -17528,6 +17622,7 @@ def test_stop_workstation_rest_bad_request( response_value.status_code = 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_workstation(request) @@ -17560,6 +17655,7 @@ def test_stop_workstation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_workstation(request) # Establish that the response is the type that we expect. @@ -17601,6 +17697,7 @@ def test_stop_workstation_rest_interceptors(null_interceptor): req.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 @@ -17647,6 +17744,7 @@ def test_generate_access_token_rest_bad_request( response_value.status_code = 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_access_token(request) @@ -17684,6 +17782,7 @@ def test_generate_access_token_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_access_token(request) # Establish that the response is the type that we expect. @@ -17724,6 +17823,7 @@ def test_generate_access_token_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = workstations.GenerateAccessTokenResponse.to_json( workstations.GenerateAccessTokenResponse() ) @@ -17775,6 +17875,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) @@ -17807,6 +17908,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) @@ -17840,6 +17942,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) @@ -17872,6 +17975,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) @@ -17905,6 +18009,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) @@ -17937,6 +18042,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) @@ -17967,6 +18073,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) @@ -17997,6 +18104,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) @@ -18027,6 +18135,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) @@ -18057,6 +18166,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) @@ -18087,6 +18197,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) @@ -18117,6 +18228,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) @@ -18147,6 +18259,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) @@ -18177,6 +18290,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-maps-addressvalidation/google/maps/addressvalidation/gapic_version.py b/packages/google-maps-addressvalidation/google/maps/addressvalidation/gapic_version.py index 7d28791e7569..558c8aab67c5 100644 --- a/packages/google-maps-addressvalidation/google/maps/addressvalidation/gapic_version.py +++ b/packages/google-maps-addressvalidation/google/maps/addressvalidation/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.3.15" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/gapic_version.py b/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/gapic_version.py index 7d28791e7569..558c8aab67c5 100644 --- a/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/gapic_version.py +++ b/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.3.15" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/async_client.py b/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/async_client.py index 48a080b30e35..64b50b967ab7 100644 --- a/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/async_client.py +++ b/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/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, @@ -48,6 +49,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AddressValidationTransport from .transports.grpc_asyncio import AddressValidationGrpcAsyncIOTransport +try: + from google.api_core import client_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 AddressValidationAsyncClient: """The service for validating addresses.""" @@ -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.maps.addressvalidation_v1.AddressValidationAsyncClient`.", + extra={ + "serviceName": "google.maps.addressvalidation.v1.AddressValidation", + "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.maps.addressvalidation.v1.AddressValidation", + "credentialsType": None, + }, + ) + async def validate_address( self, request: Optional[ @@ -263,7 +295,7 @@ async def validate_address( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> address_validation_service.ValidateAddressResponse: r"""Validates an address. @@ -299,8 +331,10 @@ async def sample_validate_address(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.addressvalidation_v1.types.ValidateAddressResponse: @@ -342,7 +376,7 @@ async def provide_validation_feedback( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> address_validation_service.ProvideValidationFeedbackResponse: r"""Feedback about the outcome of the sequence of validation attempts. This should be the last call made after a sequence of @@ -385,8 +419,10 @@ async def sample_provide_validation_feedback(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.addressvalidation_v1.types.ProvideValidationFeedbackResponse: diff --git a/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/client.py b/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/client.py index 26d9bce6ad1e..6c41992d85fe 100644 --- a/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/client.py +++ b/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/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.maps.addressvalidation_v1.types import address_validation_service from .transports.base import DEFAULT_CLIENT_INFO, AddressValidationTransport @@ -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( @@ -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.maps.addressvalidation_v1.AddressValidationClient`.", + extra={ + "serviceName": "google.maps.addressvalidation.v1.AddressValidation", + "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.maps.addressvalidation.v1.AddressValidation", + "credentialsType": None, + }, + ) + def validate_address( self, request: Optional[ @@ -633,7 +670,7 @@ def validate_address( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> address_validation_service.ValidateAddressResponse: r"""Validates an address. @@ -669,8 +706,10 @@ def sample_validate_address(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.addressvalidation_v1.types.ValidateAddressResponse: @@ -710,7 +749,7 @@ def provide_validation_feedback( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> address_validation_service.ProvideValidationFeedbackResponse: r"""Feedback about the outcome of the sequence of validation attempts. This should be the last call made after a sequence of @@ -753,8 +792,10 @@ def sample_provide_validation_feedback(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.addressvalidation_v1.types.ProvideValidationFeedbackResponse: diff --git a/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/transports/grpc.py b/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/transports/grpc.py index 4dc2d5442228..256abd8c1458 100644 --- a/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/transports/grpc.py +++ b/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/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.maps.addressvalidation_v1.types import address_validation_service from .base import DEFAULT_CLIENT_INFO, AddressValidationTransport +try: + from google.api_core import client_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.maps.addressvalidation.v1.AddressValidation", + "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.maps.addressvalidation.v1.AddressValidation", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AddressValidationGrpcTransport(AddressValidationTransport): """gRPC backend transport for AddressValidation. @@ -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 @@ -256,7 +342,7 @@ def validate_address( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "validate_address" not in self._stubs: - self._stubs["validate_address"] = self.grpc_channel.unary_unary( + self._stubs["validate_address"] = self._logged_channel.unary_unary( "/google.maps.addressvalidation.v1.AddressValidation/ValidateAddress", request_serializer=address_validation_service.ValidateAddressRequest.serialize, response_deserializer=address_validation_service.ValidateAddressResponse.deserialize, @@ -290,7 +376,9 @@ def provide_validation_feedback( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "provide_validation_feedback" not in self._stubs: - self._stubs["provide_validation_feedback"] = self.grpc_channel.unary_unary( + self._stubs[ + "provide_validation_feedback" + ] = self._logged_channel.unary_unary( "/google.maps.addressvalidation.v1.AddressValidation/ProvideValidationFeedback", request_serializer=address_validation_service.ProvideValidationFeedbackRequest.serialize, response_deserializer=address_validation_service.ProvideValidationFeedbackResponse.deserialize, @@ -298,7 +386,7 @@ def provide_validation_feedback( return self._stubs["provide_validation_feedback"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/transports/grpc_asyncio.py b/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/transports/grpc_asyncio.py index ff32b0186dc7..b992bce26056 100644 --- a/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/transports/grpc_asyncio.py +++ b/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/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.maps.addressvalidation_v1.types import address_validation_service from .base import DEFAULT_CLIENT_INFO, AddressValidationTransport from .grpc import AddressValidationGrpcTransport +try: + from google.api_core import client_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.maps.addressvalidation.v1.AddressValidation", + "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.maps.addressvalidation.v1.AddressValidation", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AddressValidationGrpcAsyncIOTransport(AddressValidationTransport): """gRPC AsyncIO backend transport for AddressValidation. @@ -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 @@ -264,7 +349,7 @@ def validate_address( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "validate_address" not in self._stubs: - self._stubs["validate_address"] = self.grpc_channel.unary_unary( + self._stubs["validate_address"] = self._logged_channel.unary_unary( "/google.maps.addressvalidation.v1.AddressValidation/ValidateAddress", request_serializer=address_validation_service.ValidateAddressRequest.serialize, response_deserializer=address_validation_service.ValidateAddressResponse.deserialize, @@ -298,7 +383,9 @@ def provide_validation_feedback( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "provide_validation_feedback" not in self._stubs: - self._stubs["provide_validation_feedback"] = self.grpc_channel.unary_unary( + self._stubs[ + "provide_validation_feedback" + ] = self._logged_channel.unary_unary( "/google.maps.addressvalidation.v1.AddressValidation/ProvideValidationFeedback", request_serializer=address_validation_service.ProvideValidationFeedbackRequest.serialize, response_deserializer=address_validation_service.ProvideValidationFeedbackResponse.deserialize, @@ -326,7 +413,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-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/transports/rest.py b/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/transports/rest.py index 1e3dec085175..beeb4f7e6cd7 100644 --- a/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/transports/rest.py +++ b/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/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,10 +93,10 @@ def post_validate_address(self, response): def pre_provide_validation_feedback( self, request: address_validation_service.ProvideValidationFeedbackRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ address_validation_service.ProvideValidationFeedbackRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for provide_validation_feedback @@ -111,9 +119,10 @@ def post_provide_validation_feedback( def pre_validate_address( self, request: address_validation_service.ValidateAddressRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - address_validation_service.ValidateAddressRequest, Sequence[Tuple[str, str]] + address_validation_service.ValidateAddressRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for validate_address @@ -256,7 +265,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> address_validation_service.ProvideValidationFeedbackResponse: r"""Call the provide validation feedback method over HTTP. @@ -268,8 +277,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.address_validation_service.ProvideValidationFeedbackResponse: @@ -283,6 +294,7 @@ def __call__( http_options = ( _BaseAddressValidationRestTransport._BaseProvideValidationFeedback._get_http_options() ) + request, metadata = self._interceptor.pre_provide_validation_feedback( request, metadata ) @@ -299,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.maps.addressvalidation_v1.AddressValidationClient.ProvideValidationFeedback", + extra={ + "serviceName": "google.maps.addressvalidation.v1.AddressValidation", + "rpcName": "ProvideValidationFeedback", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AddressValidationRestTransport._ProvideValidationFeedback._get_response( @@ -324,7 +363,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_provide_validation_feedback(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = address_validation_service.ProvideValidationFeedbackResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.maps.addressvalidation_v1.AddressValidationClient.provide_validation_feedback", + extra={ + "serviceName": "google.maps.addressvalidation.v1.AddressValidation", + "rpcName": "ProvideValidationFeedback", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ValidateAddress( @@ -363,7 +426,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> address_validation_service.ValidateAddressResponse: r"""Call the validate address method over HTTP. @@ -374,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: ~.address_validation_service.ValidateAddressResponse: @@ -387,6 +452,7 @@ def __call__( http_options = ( _BaseAddressValidationRestTransport._BaseValidateAddress._get_http_options() ) + request, metadata = self._interceptor.pre_validate_address( request, metadata ) @@ -403,6 +469,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.maps.addressvalidation_v1.AddressValidationClient.ValidateAddress", + extra={ + "serviceName": "google.maps.addressvalidation.v1.AddressValidation", + "rpcName": "ValidateAddress", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AddressValidationRestTransport._ValidateAddress._get_response( self._host, @@ -424,7 +517,33 @@ def __call__( pb_resp = address_validation_service.ValidateAddressResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_validate_address(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + address_validation_service.ValidateAddressResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.maps.addressvalidation_v1.AddressValidationClient.validate_address", + extra={ + "serviceName": "google.maps.addressvalidation.v1.AddressValidation", + "rpcName": "ValidateAddress", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-maps-addressvalidation/samples/generated_samples/snippet_metadata_google.maps.addressvalidation.v1.json b/packages/google-maps-addressvalidation/samples/generated_samples/snippet_metadata_google.maps.addressvalidation.v1.json index da0b02adbb34..f06f24bcc68e 100644 --- a/packages/google-maps-addressvalidation/samples/generated_samples/snippet_metadata_google.maps.addressvalidation.v1.json +++ b/packages/google-maps-addressvalidation/samples/generated_samples/snippet_metadata_google.maps.addressvalidation.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-maps-addressvalidation", - "version": "0.3.15" + "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.maps.addressvalidation_v1.types.ProvideValidationFeedbackResponse", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.addressvalidation_v1.types.ProvideValidationFeedbackResponse", @@ -196,7 +196,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.addressvalidation_v1.types.ValidateAddressResponse", @@ -272,7 +272,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.addressvalidation_v1.types.ValidateAddressResponse", diff --git a/packages/google-maps-addressvalidation/tests/unit/gapic/addressvalidation_v1/test_address_validation.py b/packages/google-maps-addressvalidation/tests/unit/gapic/addressvalidation_v1/test_address_validation.py index 449f14bcc3b6..9b9e29a02da4 100644 --- a/packages/google-maps-addressvalidation/tests/unit/gapic/addressvalidation_v1/test_address_validation.py +++ b/packages/google-maps-addressvalidation/tests/unit/gapic/addressvalidation_v1/test_address_validation.py @@ -1577,6 +1577,7 @@ def test_validate_address_rest_required_fields( response_value._content = json_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_address(request) @@ -1706,6 +1707,7 @@ def test_provide_validation_feedback_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.provide_validation_feedback(request) @@ -1979,6 +1981,7 @@ def test_validate_address_rest_bad_request( response_value.status_code = 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_address(request) @@ -2016,6 +2019,7 @@ def test_validate_address_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_address(request) # Establish that the response is the type that we expect. @@ -2056,6 +2060,7 @@ def test_validate_address_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = address_validation_service.ValidateAddressResponse.to_json( address_validation_service.ValidateAddressResponse() ) @@ -2102,6 +2107,7 @@ def test_provide_validation_feedback_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.provide_validation_feedback(request) @@ -2137,6 +2143,7 @@ def test_provide_validation_feedback_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.provide_validation_feedback(request) # Establish that the response is the type that we expect. @@ -2178,6 +2185,7 @@ def test_provide_validation_feedback_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = ( address_validation_service.ProvideValidationFeedbackResponse.to_json( address_validation_service.ProvideValidationFeedbackResponse() diff --git a/packages/google-maps-areainsights/google/maps/areainsights/gapic_version.py b/packages/google-maps-areainsights/google/maps/areainsights/gapic_version.py index 3b0a9d9a8d43..558c8aab67c5 100644 --- a/packages/google-maps-areainsights/google/maps/areainsights/gapic_version.py +++ b/packages/google-maps-areainsights/google/maps/areainsights/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-maps-areainsights/google/maps/areainsights_v1/gapic_version.py b/packages/google-maps-areainsights/google/maps/areainsights_v1/gapic_version.py index 3b0a9d9a8d43..558c8aab67c5 100644 --- a/packages/google-maps-areainsights/google/maps/areainsights_v1/gapic_version.py +++ b/packages/google-maps-areainsights/google/maps/areainsights_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-maps-areainsights/google/maps/areainsights_v1/services/area_insights/async_client.py b/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/async_client.py index 9a362d2be7e9..abc268950ce4 100644 --- a/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/async_client.py +++ b/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/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, @@ -48,6 +49,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AreaInsightsTransport from .transports.grpc_asyncio import AreaInsightsGrpcAsyncIOTransport +try: + from google.api_core import client_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 AreaInsightsAsyncClient: """Service definition for the Places Insights API.""" @@ -249,6 +259,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.maps.areainsights_v1.AreaInsightsAsyncClient`.", + extra={ + "serviceName": "google.maps.areainsights.v1.AreaInsights", + "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.maps.areainsights.v1.AreaInsights", + "credentialsType": None, + }, + ) + async def compute_insights( self, request: Optional[ @@ -257,7 +289,7 @@ async def compute_insights( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> area_insights_service.ComputeInsightsResponse: r"""Compute Insights RPC @@ -305,8 +337,10 @@ async def sample_compute_insights(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.areainsights_v1.types.ComputeInsightsResponse: diff --git a/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/client.py b/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/client.py index 1fa5002fff98..cc74d9930ca8 100644 --- a/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/client.py +++ b/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/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.maps.areainsights_v1.types import area_insights_service from .transports.base import DEFAULT_CLIENT_INFO, AreaInsightsTransport @@ -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( @@ -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.maps.areainsights_v1.AreaInsightsClient`.", + extra={ + "serviceName": "google.maps.areainsights.v1.AreaInsights", + "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.maps.areainsights.v1.AreaInsights", + "credentialsType": None, + }, + ) + def compute_insights( self, request: Optional[ @@ -638,7 +675,7 @@ def compute_insights( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> area_insights_service.ComputeInsightsResponse: r"""Compute Insights RPC @@ -686,8 +723,10 @@ def sample_compute_insights(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.areainsights_v1.types.ComputeInsightsResponse: diff --git a/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/transports/grpc.py b/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/transports/grpc.py index 9f02613a9af3..2ce72e6206fc 100644 --- a/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/transports/grpc.py +++ b/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/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.maps.areainsights_v1.types import area_insights_service from .base import DEFAULT_CLIENT_INFO, AreaInsightsTransport +try: + from google.api_core import client_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.maps.areainsights.v1.AreaInsights", + "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.maps.areainsights.v1.AreaInsights", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AreaInsightsGrpcTransport(AreaInsightsTransport): """gRPC backend transport for AreaInsights. @@ -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 @@ -268,7 +354,7 @@ def compute_insights( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "compute_insights" not in self._stubs: - self._stubs["compute_insights"] = self.grpc_channel.unary_unary( + self._stubs["compute_insights"] = self._logged_channel.unary_unary( "/google.maps.areainsights.v1.AreaInsights/ComputeInsights", request_serializer=area_insights_service.ComputeInsightsRequest.serialize, response_deserializer=area_insights_service.ComputeInsightsResponse.deserialize, @@ -276,7 +362,7 @@ def compute_insights( return self._stubs["compute_insights"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/transports/grpc_asyncio.py b/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/transports/grpc_asyncio.py index 43a46e9c3ee8..38c4e5963457 100644 --- a/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/transports/grpc_asyncio.py +++ b/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/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.maps.areainsights_v1.types import area_insights_service from .base import DEFAULT_CLIENT_INFO, AreaInsightsTransport from .grpc import AreaInsightsGrpcTransport +try: + from google.api_core import client_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.maps.areainsights.v1.AreaInsights", + "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.maps.areainsights.v1.AreaInsights", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AreaInsightsGrpcAsyncIOTransport(AreaInsightsTransport): """gRPC AsyncIO backend transport for AreaInsights. @@ -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 @@ -276,7 +361,7 @@ def compute_insights( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "compute_insights" not in self._stubs: - self._stubs["compute_insights"] = self.grpc_channel.unary_unary( + self._stubs["compute_insights"] = self._logged_channel.unary_unary( "/google.maps.areainsights.v1.AreaInsights/ComputeInsights", request_serializer=area_insights_service.ComputeInsightsRequest.serialize, response_deserializer=area_insights_service.ComputeInsightsResponse.deserialize, @@ -308,7 +393,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-maps-areainsights/google/maps/areainsights_v1/services/area_insights/transports/rest.py b/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/transports/rest.py index 0ed30438f8f9..7ada4148c778 100644 --- a/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/transports/rest.py +++ b/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/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,11 @@ def post_compute_insights(self, response): def pre_compute_insights( self, request: area_insights_service.ComputeInsightsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[area_insights_service.ComputeInsightsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + area_insights_service.ComputeInsightsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for compute_insights Override in a subclass to manipulate the request or metadata @@ -219,7 +230,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> area_insights_service.ComputeInsightsResponse: r"""Call the compute insights method over HTTP. @@ -229,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: ~.area_insights_service.ComputeInsightsResponse: @@ -240,6 +253,7 @@ def __call__( http_options = ( _BaseAreaInsightsRestTransport._BaseComputeInsights._get_http_options() ) + request, metadata = self._interceptor.pre_compute_insights( request, metadata ) @@ -256,6 +270,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.maps.areainsights_v1.AreaInsightsClient.ComputeInsights", + extra={ + "serviceName": "google.maps.areainsights.v1.AreaInsights", + "rpcName": "ComputeInsights", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AreaInsightsRestTransport._ComputeInsights._get_response( self._host, @@ -277,7 +318,31 @@ def __call__( pb_resp = area_insights_service.ComputeInsightsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_compute_insights(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + area_insights_service.ComputeInsightsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.maps.areainsights_v1.AreaInsightsClient.compute_insights", + extra={ + "serviceName": "google.maps.areainsights.v1.AreaInsights", + "rpcName": "ComputeInsights", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-maps-areainsights/samples/generated_samples/snippet_metadata_google.maps.areainsights.v1.json b/packages/google-maps-areainsights/samples/generated_samples/snippet_metadata_google.maps.areainsights.v1.json index ae71f98810a5..3e131934c793 100644 --- a/packages/google-maps-areainsights/samples/generated_samples/snippet_metadata_google.maps.areainsights.v1.json +++ b/packages/google-maps-areainsights/samples/generated_samples/snippet_metadata_google.maps.areainsights.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-maps-areainsights", - "version": "0.1.2" + "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.maps.areainsights_v1.types.ComputeInsightsResponse", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.areainsights_v1.types.ComputeInsightsResponse", diff --git a/packages/google-maps-areainsights/tests/unit/gapic/areainsights_v1/test_area_insights.py b/packages/google-maps-areainsights/tests/unit/gapic/areainsights_v1/test_area_insights.py index 67fe9d1538a3..9fc86c87b8ea 100644 --- a/packages/google-maps-areainsights/tests/unit/gapic/areainsights_v1/test_area_insights.py +++ b/packages/google-maps-areainsights/tests/unit/gapic/areainsights_v1/test_area_insights.py @@ -1318,6 +1318,7 @@ def test_compute_insights_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.compute_insights(request) @@ -1539,6 +1540,7 @@ def test_compute_insights_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.compute_insights(request) @@ -1574,6 +1576,7 @@ def test_compute_insights_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.compute_insights(request) # Establish that the response is the type that we expect. @@ -1614,6 +1617,7 @@ def test_compute_insights_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = area_insights_service.ComputeInsightsResponse.to_json( area_insights_service.ComputeInsightsResponse() ) diff --git a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery/gapic_version.py b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery/gapic_version.py index ed547981b7d6..558c8aab67c5 100644 --- a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery/gapic_version.py +++ b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery/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-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/gapic_version.py b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/gapic_version.py index ed547981b7d6..558c8aab67c5 100644 --- a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/gapic_version.py +++ b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_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-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/async_client.py b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/async_client.py index 91ee9321250f..a4572c9dd5a9 100644 --- a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/async_client.py +++ b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_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, DeliveryServiceTransport from .transports.grpc_asyncio import DeliveryServiceGrpcAsyncIOTransport +try: + from google.api_core import client_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 DeliveryServiceAsyncClient: """The Last Mile Delivery service.""" @@ -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 `maps.fleetengine.delivery_v1.DeliveryServiceAsyncClient`.", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "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": "maps.fleetengine.delivery.v1.DeliveryService", + "credentialsType": None, + }, + ) + async def create_delivery_vehicle( self, request: Optional[ @@ -289,7 +321,7 @@ async def create_delivery_vehicle( delivery_vehicle_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]]] = (), ) -> delivery_vehicles.DeliveryVehicle: r"""Creates and returns a new ``DeliveryVehicle``. @@ -365,8 +397,10 @@ async def sample_create_delivery_vehicle(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_delivery_v1.types.DeliveryVehicle: @@ -446,7 +480,7 @@ async def get_delivery_vehicle( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> delivery_vehicles.DeliveryVehicle: r"""Returns the specified ``DeliveryVehicle`` instance. @@ -491,8 +525,10 @@ async def sample_get_delivery_vehicle(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_delivery_v1.types.DeliveryVehicle: @@ -571,7 +607,7 @@ async def update_delivery_vehicle( 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]]] = (), ) -> delivery_vehicles.DeliveryVehicle: r"""Writes updated ``DeliveryVehicle`` data to Fleet Engine, and assigns ``Tasks`` to the ``DeliveryVehicle``. You cannot update @@ -634,8 +670,10 @@ async def sample_update_delivery_vehicle(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_delivery_v1.types.DeliveryVehicle: @@ -712,7 +750,7 @@ async def batch_create_tasks( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> delivery_api.BatchCreateTasksResponse: r"""Creates and returns a batch of new ``Task`` objects. @@ -755,8 +793,10 @@ async def sample_batch_create_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.maps.fleetengine_delivery_v1.types.BatchCreateTasksResponse: @@ -809,7 +849,7 @@ async def create_task( task_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]]] = (), ) -> tasks.Task: r"""Creates and returns a new ``Task`` object. @@ -897,8 +937,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.maps.fleetengine_delivery_v1.types.Task: @@ -983,7 +1025,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]]] = (), ) -> tasks.Task: r"""Gets information about a ``Task``. @@ -1028,8 +1070,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.maps.fleetengine_delivery_v1.types.Task: @@ -1109,7 +1153,7 @@ async def update_task( 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]]] = (), ) -> tasks.Task: r"""Updates ``Task`` data. @@ -1184,8 +1228,10 @@ async def sample_update_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.maps.fleetengine_delivery_v1.types.Task: @@ -1268,7 +1314,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"""Gets all ``Task``\ s that meet the specified filtering criteria. @@ -1314,8 +1360,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.maps.fleetengine_delivery_v1.services.delivery_service.pagers.ListTasksAsyncPager: @@ -1396,7 +1444,7 @@ async def get_task_tracking_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]]] = (), ) -> task_tracking_info.TaskTrackingInfo: r"""Returns the specified ``TaskTrackingInfo`` instance. @@ -1443,8 +1491,10 @@ async def sample_get_task_tracking_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.maps.fleetengine_delivery_v1.types.TaskTrackingInfo: @@ -1514,7 +1564,7 @@ async def list_delivery_vehicles( 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.ListDeliveryVehiclesAsyncPager: r"""Gets all ``DeliveryVehicle``\ s that meet the specified filtering criteria. @@ -1561,8 +1611,10 @@ async def sample_list_delivery_vehicles(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_delivery_v1.services.delivery_service.pagers.ListDeliveryVehiclesAsyncPager: diff --git a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/client.py b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/client.py index 157b80bfadf4..0c0ba1dce657 100644 --- a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/client.py +++ b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_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 duration_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -625,6 +635,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( @@ -690,6 +704,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 `maps.fleetengine.delivery_v1.DeliveryServiceClient`.", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "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": "maps.fleetengine.delivery.v1.DeliveryService", + "credentialsType": None, + }, + ) + def create_delivery_vehicle( self, request: Optional[ @@ -701,7 +738,7 @@ def create_delivery_vehicle( delivery_vehicle_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]]] = (), ) -> delivery_vehicles.DeliveryVehicle: r"""Creates and returns a new ``DeliveryVehicle``. @@ -777,8 +814,10 @@ def sample_create_delivery_vehicle(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_delivery_v1.types.DeliveryVehicle: @@ -855,7 +894,7 @@ def get_delivery_vehicle( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> delivery_vehicles.DeliveryVehicle: r"""Returns the specified ``DeliveryVehicle`` instance. @@ -900,8 +939,10 @@ def sample_get_delivery_vehicle(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_delivery_v1.types.DeliveryVehicle: @@ -977,7 +1018,7 @@ def update_delivery_vehicle( 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]]] = (), ) -> delivery_vehicles.DeliveryVehicle: r"""Writes updated ``DeliveryVehicle`` data to Fleet Engine, and assigns ``Tasks`` to the ``DeliveryVehicle``. You cannot update @@ -1040,8 +1081,10 @@ def sample_update_delivery_vehicle(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_delivery_v1.types.DeliveryVehicle: @@ -1115,7 +1158,7 @@ def batch_create_tasks( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> delivery_api.BatchCreateTasksResponse: r"""Creates and returns a batch of new ``Task`` objects. @@ -1158,8 +1201,10 @@ def sample_batch_create_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.maps.fleetengine_delivery_v1.types.BatchCreateTasksResponse: @@ -1210,7 +1255,7 @@ def create_task( task_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]]] = (), ) -> tasks.Task: r"""Creates and returns a new ``Task`` object. @@ -1298,8 +1343,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.maps.fleetengine_delivery_v1.types.Task: @@ -1381,7 +1428,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]]] = (), ) -> tasks.Task: r"""Gets information about a ``Task``. @@ -1426,8 +1473,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.maps.fleetengine_delivery_v1.types.Task: @@ -1506,7 +1555,7 @@ def update_task( 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]]] = (), ) -> tasks.Task: r"""Updates ``Task`` data. @@ -1581,8 +1630,10 @@ def sample_update_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.maps.fleetengine_delivery_v1.types.Task: @@ -1662,7 +1713,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"""Gets all ``Task``\ s that meet the specified filtering criteria. @@ -1708,8 +1759,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.maps.fleetengine_delivery_v1.services.delivery_service.pagers.ListTasksPager: @@ -1787,7 +1840,7 @@ def get_task_tracking_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]]] = (), ) -> task_tracking_info.TaskTrackingInfo: r"""Returns the specified ``TaskTrackingInfo`` instance. @@ -1834,8 +1887,10 @@ def sample_get_task_tracking_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.maps.fleetengine_delivery_v1.types.TaskTrackingInfo: @@ -1902,7 +1957,7 @@ def list_delivery_vehicles( 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.ListDeliveryVehiclesPager: r"""Gets all ``DeliveryVehicle``\ s that meet the specified filtering criteria. @@ -1949,8 +2004,10 @@ def sample_list_delivery_vehicles(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_delivery_v1.services.delivery_service.pagers.ListDeliveryVehiclesPager: diff --git a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/pagers.py b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/pagers.py index b645b3ca097f..b8cddd19d315 100644 --- a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/pagers.py +++ b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/pagers.py @@ -71,7 +71,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -85,8 +85,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = delivery_api.ListTasksRequest(request) @@ -145,7 +147,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. @@ -159,8 +161,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 = delivery_api.ListTasksRequest(request) @@ -223,7 +227,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -237,8 +241,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = delivery_api.ListDeliveryVehiclesRequest(request) @@ -297,7 +303,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. @@ -311,8 +317,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 = delivery_api.ListDeliveryVehiclesRequest(request) diff --git a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/transports/grpc.py b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/transports/grpc.py index 7b90392f5a79..abfd09fc1a50 100644 --- a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/transports/grpc.py +++ b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_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,7 +23,10 @@ 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.maps.fleetengine_delivery_v1.types import ( delivery_api, @@ -31,6 +37,81 @@ from .base import DEFAULT_CLIENT_INFO, DeliveryServiceTransport +try: + from google.api_core import client_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": "maps.fleetengine.delivery.v1.DeliveryService", + "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": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class DeliveryServiceGrpcTransport(DeliveryServiceTransport): """gRPC backend transport for DeliveryService. @@ -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 @@ -260,7 +346,7 @@ def create_delivery_vehicle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_delivery_vehicle" not in self._stubs: - self._stubs["create_delivery_vehicle"] = self.grpc_channel.unary_unary( + self._stubs["create_delivery_vehicle"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/CreateDeliveryVehicle", request_serializer=delivery_api.CreateDeliveryVehicleRequest.serialize, response_deserializer=delivery_vehicles.DeliveryVehicle.deserialize, @@ -288,7 +374,7 @@ def get_delivery_vehicle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_delivery_vehicle" not in self._stubs: - self._stubs["get_delivery_vehicle"] = self.grpc_channel.unary_unary( + self._stubs["get_delivery_vehicle"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/GetDeliveryVehicle", request_serializer=delivery_api.GetDeliveryVehicleRequest.serialize, response_deserializer=delivery_vehicles.DeliveryVehicle.deserialize, @@ -324,7 +410,7 @@ def update_delivery_vehicle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_delivery_vehicle" not in self._stubs: - self._stubs["update_delivery_vehicle"] = self.grpc_channel.unary_unary( + self._stubs["update_delivery_vehicle"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/UpdateDeliveryVehicle", request_serializer=delivery_api.UpdateDeliveryVehicleRequest.serialize, response_deserializer=delivery_vehicles.DeliveryVehicle.deserialize, @@ -352,7 +438,7 @@ def batch_create_tasks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_tasks" not in self._stubs: - self._stubs["batch_create_tasks"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_tasks"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/BatchCreateTasks", request_serializer=delivery_api.BatchCreateTasksRequest.serialize, response_deserializer=delivery_api.BatchCreateTasksResponse.deserialize, @@ -376,7 +462,7 @@ def create_task(self) -> Callable[[delivery_api.CreateTaskRequest], tasks.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( "/maps.fleetengine.delivery.v1.DeliveryService/CreateTask", request_serializer=delivery_api.CreateTaskRequest.serialize, response_deserializer=tasks.Task.deserialize, @@ -400,7 +486,7 @@ def get_task(self) -> Callable[[delivery_api.GetTaskRequest], tasks.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( "/maps.fleetengine.delivery.v1.DeliveryService/GetTask", request_serializer=delivery_api.GetTaskRequest.serialize, response_deserializer=tasks.Task.deserialize, @@ -424,7 +510,7 @@ def update_task(self) -> Callable[[delivery_api.UpdateTaskRequest], tasks.Task]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_task" not in self._stubs: - self._stubs["update_task"] = self.grpc_channel.unary_unary( + self._stubs["update_task"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/UpdateTask", request_serializer=delivery_api.UpdateTaskRequest.serialize, response_deserializer=tasks.Task.deserialize, @@ -450,7 +536,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( "/maps.fleetengine.delivery.v1.DeliveryService/ListTasks", request_serializer=delivery_api.ListTasksRequest.serialize, response_deserializer=delivery_api.ListTasksResponse.deserialize, @@ -478,7 +564,7 @@ def get_task_tracking_info( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_task_tracking_info" not in self._stubs: - self._stubs["get_task_tracking_info"] = self.grpc_channel.unary_unary( + self._stubs["get_task_tracking_info"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/GetTaskTrackingInfo", request_serializer=delivery_api.GetTaskTrackingInfoRequest.serialize, response_deserializer=task_tracking_info.TaskTrackingInfo.deserialize, @@ -508,7 +594,7 @@ def list_delivery_vehicles( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_delivery_vehicles" not in self._stubs: - self._stubs["list_delivery_vehicles"] = self.grpc_channel.unary_unary( + self._stubs["list_delivery_vehicles"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/ListDeliveryVehicles", request_serializer=delivery_api.ListDeliveryVehiclesRequest.serialize, response_deserializer=delivery_api.ListDeliveryVehiclesResponse.deserialize, @@ -516,7 +602,7 @@ def list_delivery_vehicles( return self._stubs["list_delivery_vehicles"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/transports/grpc_asyncio.py b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/transports/grpc_asyncio.py index bbd2979ba6a6..a6f8b24a0896 100644 --- a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/transports/grpc_asyncio.py +++ b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_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,8 +25,11 @@ 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.maps.fleetengine_delivery_v1.types import ( delivery_api, @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, DeliveryServiceTransport from .grpc import DeliveryServiceGrpcTransport +try: + from google.api_core import client_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": "maps.fleetengine.delivery.v1.DeliveryService", + "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": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class DeliveryServiceGrpcAsyncIOTransport(DeliveryServiceTransport): """gRPC AsyncIO backend transport for DeliveryService. @@ -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 create_delivery_vehicle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_delivery_vehicle" not in self._stubs: - self._stubs["create_delivery_vehicle"] = self.grpc_channel.unary_unary( + self._stubs["create_delivery_vehicle"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/CreateDeliveryVehicle", request_serializer=delivery_api.CreateDeliveryVehicleRequest.serialize, response_deserializer=delivery_vehicles.DeliveryVehicle.deserialize, @@ -298,7 +383,7 @@ def get_delivery_vehicle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_delivery_vehicle" not in self._stubs: - self._stubs["get_delivery_vehicle"] = self.grpc_channel.unary_unary( + self._stubs["get_delivery_vehicle"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/GetDeliveryVehicle", request_serializer=delivery_api.GetDeliveryVehicleRequest.serialize, response_deserializer=delivery_vehicles.DeliveryVehicle.deserialize, @@ -335,7 +420,7 @@ def update_delivery_vehicle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_delivery_vehicle" not in self._stubs: - self._stubs["update_delivery_vehicle"] = self.grpc_channel.unary_unary( + self._stubs["update_delivery_vehicle"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/UpdateDeliveryVehicle", request_serializer=delivery_api.UpdateDeliveryVehicleRequest.serialize, response_deserializer=delivery_vehicles.DeliveryVehicle.deserialize, @@ -364,7 +449,7 @@ def batch_create_tasks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_tasks" not in self._stubs: - self._stubs["batch_create_tasks"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_tasks"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/BatchCreateTasks", request_serializer=delivery_api.BatchCreateTasksRequest.serialize, response_deserializer=delivery_api.BatchCreateTasksResponse.deserialize, @@ -390,7 +475,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( "/maps.fleetengine.delivery.v1.DeliveryService/CreateTask", request_serializer=delivery_api.CreateTaskRequest.serialize, response_deserializer=tasks.Task.deserialize, @@ -416,7 +501,7 @@ def get_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( "/maps.fleetengine.delivery.v1.DeliveryService/GetTask", request_serializer=delivery_api.GetTaskRequest.serialize, response_deserializer=tasks.Task.deserialize, @@ -442,7 +527,7 @@ def update_task( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_task" not in self._stubs: - self._stubs["update_task"] = self.grpc_channel.unary_unary( + self._stubs["update_task"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/UpdateTask", request_serializer=delivery_api.UpdateTaskRequest.serialize, response_deserializer=tasks.Task.deserialize, @@ -470,7 +555,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( "/maps.fleetengine.delivery.v1.DeliveryService/ListTasks", request_serializer=delivery_api.ListTasksRequest.serialize, response_deserializer=delivery_api.ListTasksResponse.deserialize, @@ -499,7 +584,7 @@ def get_task_tracking_info( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_task_tracking_info" not in self._stubs: - self._stubs["get_task_tracking_info"] = self.grpc_channel.unary_unary( + self._stubs["get_task_tracking_info"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/GetTaskTrackingInfo", request_serializer=delivery_api.GetTaskTrackingInfoRequest.serialize, response_deserializer=task_tracking_info.TaskTrackingInfo.deserialize, @@ -529,7 +614,7 @@ def list_delivery_vehicles( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_delivery_vehicles" not in self._stubs: - self._stubs["list_delivery_vehicles"] = self.grpc_channel.unary_unary( + self._stubs["list_delivery_vehicles"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/ListDeliveryVehicles", request_serializer=delivery_api.ListDeliveryVehiclesRequest.serialize, response_deserializer=delivery_api.ListDeliveryVehiclesResponse.deserialize, @@ -687,7 +772,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-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/transports/rest.py b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/transports/rest.py index aef58bf5045a..faf87ef68d72 100644 --- a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/transports/rest.py +++ b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_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, @@ -154,8 +162,10 @@ def post_update_task(self, response): def pre_batch_create_tasks( self, request: delivery_api.BatchCreateTasksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[delivery_api.BatchCreateTasksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + delivery_api.BatchCreateTasksRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_create_tasks Override in a subclass to manipulate the request or metadata @@ -177,8 +187,11 @@ def post_batch_create_tasks( def pre_create_delivery_vehicle( self, request: delivery_api.CreateDeliveryVehicleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[delivery_api.CreateDeliveryVehicleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + delivery_api.CreateDeliveryVehicleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_delivery_vehicle Override in a subclass to manipulate the request or metadata @@ -200,8 +213,8 @@ def post_create_delivery_vehicle( def pre_create_task( self, request: delivery_api.CreateTaskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[delivery_api.CreateTaskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[delivery_api.CreateTaskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_task Override in a subclass to manipulate the request or metadata @@ -221,8 +234,10 @@ def post_create_task(self, response: tasks.Task) -> tasks.Task: def pre_get_delivery_vehicle( self, request: delivery_api.GetDeliveryVehicleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[delivery_api.GetDeliveryVehicleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + delivery_api.GetDeliveryVehicleRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_delivery_vehicle Override in a subclass to manipulate the request or metadata @@ -242,8 +257,10 @@ def post_get_delivery_vehicle( return response def pre_get_task( - self, request: delivery_api.GetTaskRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[delivery_api.GetTaskRequest, Sequence[Tuple[str, str]]]: + self, + request: delivery_api.GetTaskRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[delivery_api.GetTaskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_task Override in a subclass to manipulate the request or metadata @@ -263,8 +280,10 @@ def post_get_task(self, response: tasks.Task) -> tasks.Task: def pre_get_task_tracking_info( self, request: delivery_api.GetTaskTrackingInfoRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[delivery_api.GetTaskTrackingInfoRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + delivery_api.GetTaskTrackingInfoRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_task_tracking_info Override in a subclass to manipulate the request or metadata @@ -286,8 +305,11 @@ def post_get_task_tracking_info( def pre_list_delivery_vehicles( self, request: delivery_api.ListDeliveryVehiclesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[delivery_api.ListDeliveryVehiclesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + delivery_api.ListDeliveryVehiclesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_delivery_vehicles Override in a subclass to manipulate the request or metadata @@ -309,8 +331,8 @@ def post_list_delivery_vehicles( def pre_list_tasks( self, request: delivery_api.ListTasksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[delivery_api.ListTasksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[delivery_api.ListTasksRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_tasks Override in a subclass to manipulate the request or metadata @@ -332,8 +354,11 @@ def post_list_tasks( def pre_update_delivery_vehicle( self, request: delivery_api.UpdateDeliveryVehicleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[delivery_api.UpdateDeliveryVehicleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + delivery_api.UpdateDeliveryVehicleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_delivery_vehicle Override in a subclass to manipulate the request or metadata @@ -355,8 +380,8 @@ def post_update_delivery_vehicle( def pre_update_task( self, request: delivery_api.UpdateTaskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[delivery_api.UpdateTaskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[delivery_api.UpdateTaskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_task Override in a subclass to manipulate the request or metadata @@ -495,7 +520,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> delivery_api.BatchCreateTasksResponse: r"""Call the batch create tasks method over HTTP. @@ -505,8 +530,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.delivery_api.BatchCreateTasksResponse: @@ -516,6 +543,7 @@ def __call__( http_options = ( _BaseDeliveryServiceRestTransport._BaseBatchCreateTasks._get_http_options() ) + request, metadata = self._interceptor.pre_batch_create_tasks( request, metadata ) @@ -532,6 +560,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for maps.fleetengine.delivery_v1.DeliveryServiceClient.BatchCreateTasks", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "BatchCreateTasks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DeliveryServiceRestTransport._BatchCreateTasks._get_response( self._host, @@ -553,7 +608,31 @@ def __call__( pb_resp = delivery_api.BatchCreateTasksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_create_tasks(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = delivery_api.BatchCreateTasksResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for maps.fleetengine.delivery_v1.DeliveryServiceClient.batch_create_tasks", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "BatchCreateTasks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateDeliveryVehicle( @@ -592,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]]] = (), ) -> delivery_vehicles.DeliveryVehicle: r"""Call the create delivery vehicle method over HTTP. @@ -602,8 +681,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.delivery_vehicles.DeliveryVehicle: @@ -625,6 +706,7 @@ def __call__( http_options = ( _BaseDeliveryServiceRestTransport._BaseCreateDeliveryVehicle._get_http_options() ) + request, metadata = self._interceptor.pre_create_delivery_vehicle( request, metadata ) @@ -641,6 +723,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for maps.fleetengine.delivery_v1.DeliveryServiceClient.CreateDeliveryVehicle", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "CreateDeliveryVehicle", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( DeliveryServiceRestTransport._CreateDeliveryVehicle._get_response( @@ -664,7 +773,31 @@ def __call__( pb_resp = delivery_vehicles.DeliveryVehicle.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_delivery_vehicle(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = delivery_vehicles.DeliveryVehicle.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for maps.fleetengine.delivery_v1.DeliveryServiceClient.create_delivery_vehicle", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "CreateDeliveryVehicle", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateTask( @@ -702,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]]] = (), ) -> tasks.Task: r"""Call the create task method over HTTP. @@ -712,8 +845,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.tasks.Task: @@ -739,6 +874,7 @@ def __call__( http_options = ( _BaseDeliveryServiceRestTransport._BaseCreateTask._get_http_options() ) + request, metadata = self._interceptor.pre_create_task(request, metadata) transcoded_request = _BaseDeliveryServiceRestTransport._BaseCreateTask._get_transcoded_request( http_options, request @@ -753,6 +889,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for maps.fleetengine.delivery_v1.DeliveryServiceClient.CreateTask", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "CreateTask", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DeliveryServiceRestTransport._CreateTask._get_response( self._host, @@ -774,7 +937,29 @@ def __call__( pb_resp = tasks.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 = tasks.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 maps.fleetengine.delivery_v1.DeliveryServiceClient.create_task", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "CreateTask", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDeliveryVehicle( @@ -812,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]]] = (), ) -> delivery_vehicles.DeliveryVehicle: r"""Call the get delivery vehicle method over HTTP. @@ -822,8 +1007,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.delivery_vehicles.DeliveryVehicle: @@ -845,6 +1032,7 @@ def __call__( http_options = ( _BaseDeliveryServiceRestTransport._BaseGetDeliveryVehicle._get_http_options() ) + request, metadata = self._interceptor.pre_get_delivery_vehicle( request, metadata ) @@ -857,6 +1045,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for maps.fleetengine.delivery_v1.DeliveryServiceClient.GetDeliveryVehicle", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "GetDeliveryVehicle", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DeliveryServiceRestTransport._GetDeliveryVehicle._get_response( self._host, @@ -877,7 +1092,31 @@ def __call__( pb_resp = delivery_vehicles.DeliveryVehicle.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_delivery_vehicle(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = delivery_vehicles.DeliveryVehicle.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for maps.fleetengine.delivery_v1.DeliveryServiceClient.get_delivery_vehicle", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "GetDeliveryVehicle", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTask( @@ -914,7 +1153,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tasks.Task: r"""Call the get task method over HTTP. @@ -924,8 +1163,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.tasks.Task: @@ -951,6 +1192,7 @@ def __call__( http_options = ( _BaseDeliveryServiceRestTransport._BaseGetTask._get_http_options() ) + request, metadata = self._interceptor.pre_get_task(request, metadata) transcoded_request = ( _BaseDeliveryServiceRestTransport._BaseGetTask._get_transcoded_request( @@ -965,6 +1207,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for maps.fleetengine.delivery_v1.DeliveryServiceClient.GetTask", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "GetTask", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DeliveryServiceRestTransport._GetTask._get_response( self._host, @@ -985,7 +1254,29 @@ def __call__( pb_resp = tasks.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 = tasks.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 maps.fleetengine.delivery_v1.DeliveryServiceClient.get_task", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "GetTask", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTaskTrackingInfo( @@ -1023,7 +1314,7 @@ 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_tracking_info.TaskTrackingInfo: r"""Call the get task tracking info method over HTTP. @@ -1033,8 +1324,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_tracking_info.TaskTrackingInfo: @@ -1049,6 +1342,7 @@ def __call__( http_options = ( _BaseDeliveryServiceRestTransport._BaseGetTaskTrackingInfo._get_http_options() ) + request, metadata = self._interceptor.pre_get_task_tracking_info( request, metadata ) @@ -1061,6 +1355,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for maps.fleetengine.delivery_v1.DeliveryServiceClient.GetTaskTrackingInfo", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "GetTaskTrackingInfo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DeliveryServiceRestTransport._GetTaskTrackingInfo._get_response( self._host, @@ -1081,7 +1402,31 @@ def __call__( pb_resp = task_tracking_info.TaskTrackingInfo.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_task_tracking_info(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = task_tracking_info.TaskTrackingInfo.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for maps.fleetengine.delivery_v1.DeliveryServiceClient.get_task_tracking_info", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "GetTaskTrackingInfo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDeliveryVehicles( @@ -1119,7 +1464,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> delivery_api.ListDeliveryVehiclesResponse: r"""Call the list delivery vehicles method over HTTP. @@ -1129,8 +1474,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.delivery_api.ListDeliveryVehiclesResponse: @@ -1140,6 +1487,7 @@ def __call__( http_options = ( _BaseDeliveryServiceRestTransport._BaseListDeliveryVehicles._get_http_options() ) + request, metadata = self._interceptor.pre_list_delivery_vehicles( request, metadata ) @@ -1152,6 +1500,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for maps.fleetengine.delivery_v1.DeliveryServiceClient.ListDeliveryVehicles", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "ListDeliveryVehicles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DeliveryServiceRestTransport._ListDeliveryVehicles._get_response( self._host, @@ -1172,7 +1547,31 @@ def __call__( pb_resp = delivery_api.ListDeliveryVehiclesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_delivery_vehicles(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + delivery_api.ListDeliveryVehiclesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for maps.fleetengine.delivery_v1.DeliveryServiceClient.list_delivery_vehicles", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "ListDeliveryVehicles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTasks( @@ -1209,7 +1608,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> delivery_api.ListTasksResponse: r"""Call the list tasks method over HTTP. @@ -1219,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: ~.delivery_api.ListTasksResponse: @@ -1233,6 +1634,7 @@ def __call__( http_options = ( _BaseDeliveryServiceRestTransport._BaseListTasks._get_http_options() ) + request, metadata = self._interceptor.pre_list_tasks(request, metadata) transcoded_request = _BaseDeliveryServiceRestTransport._BaseListTasks._get_transcoded_request( http_options, request @@ -1245,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 = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for maps.fleetengine.delivery_v1.DeliveryServiceClient.ListTasks", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "ListTasks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DeliveryServiceRestTransport._ListTasks._get_response( self._host, @@ -1265,7 +1694,29 @@ def __call__( pb_resp = delivery_api.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 = delivery_api.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 maps.fleetengine.delivery_v1.DeliveryServiceClient.list_tasks", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "ListTasks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDeliveryVehicle( @@ -1304,7 +1755,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> delivery_vehicles.DeliveryVehicle: r"""Call the update delivery vehicle method over HTTP. @@ -1314,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: ~.delivery_vehicles.DeliveryVehicle: @@ -1337,6 +1790,7 @@ def __call__( http_options = ( _BaseDeliveryServiceRestTransport._BaseUpdateDeliveryVehicle._get_http_options() ) + request, metadata = self._interceptor.pre_update_delivery_vehicle( request, metadata ) @@ -1353,6 +1807,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for maps.fleetengine.delivery_v1.DeliveryServiceClient.UpdateDeliveryVehicle", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "UpdateDeliveryVehicle", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( DeliveryServiceRestTransport._UpdateDeliveryVehicle._get_response( @@ -1376,7 +1857,31 @@ def __call__( pb_resp = delivery_vehicles.DeliveryVehicle.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_delivery_vehicle(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = delivery_vehicles.DeliveryVehicle.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for maps.fleetengine.delivery_v1.DeliveryServiceClient.update_delivery_vehicle", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "UpdateDeliveryVehicle", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateTask( @@ -1414,7 +1919,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tasks.Task: r"""Call the update task method over HTTP. @@ -1424,8 +1929,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.tasks.Task: @@ -1451,6 +1958,7 @@ def __call__( http_options = ( _BaseDeliveryServiceRestTransport._BaseUpdateTask._get_http_options() ) + request, metadata = self._interceptor.pre_update_task(request, metadata) transcoded_request = _BaseDeliveryServiceRestTransport._BaseUpdateTask._get_transcoded_request( http_options, request @@ -1465,6 +1973,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for maps.fleetengine.delivery_v1.DeliveryServiceClient.UpdateTask", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "UpdateTask", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DeliveryServiceRestTransport._UpdateTask._get_response( self._host, @@ -1486,7 +2021,29 @@ def __call__( pb_resp = tasks.Task.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_task(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tasks.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 maps.fleetengine.delivery_v1.DeliveryServiceClient.update_task", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "UpdateTask", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-maps-fleetengine-delivery/samples/generated_samples/snippet_metadata_maps.fleetengine.delivery.v1.json b/packages/google-maps-fleetengine-delivery/samples/generated_samples/snippet_metadata_maps.fleetengine.delivery.v1.json index ea6c4de1fa77..b1bb486cd03d 100644 --- a/packages/google-maps-fleetengine-delivery/samples/generated_samples/snippet_metadata_maps.fleetengine.delivery.v1.json +++ b/packages/google-maps-fleetengine-delivery/samples/generated_samples/snippet_metadata_maps.fleetengine.delivery.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-maps-fleetengine-delivery", - "version": "0.2.6" + "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.maps.fleetengine_delivery_v1.types.BatchCreateTasksResponse", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.BatchCreateTasksResponse", @@ -208,7 +208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.DeliveryVehicle", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.DeliveryVehicle", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.Task", @@ -473,7 +473,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.Task", @@ -554,7 +554,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.DeliveryVehicle", @@ -634,7 +634,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.DeliveryVehicle", @@ -715,7 +715,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.TaskTrackingInfo", @@ -795,7 +795,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.TaskTrackingInfo", @@ -876,7 +876,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.Task", @@ -956,7 +956,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.Task", @@ -1037,7 +1037,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.services.delivery_service.pagers.ListDeliveryVehiclesAsyncPager", @@ -1117,7 +1117,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.services.delivery_service.pagers.ListDeliveryVehiclesPager", @@ -1198,7 +1198,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.services.delivery_service.pagers.ListTasksAsyncPager", @@ -1278,7 +1278,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.services.delivery_service.pagers.ListTasksPager", @@ -1363,7 +1363,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.DeliveryVehicle", @@ -1447,7 +1447,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.DeliveryVehicle", @@ -1532,7 +1532,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.Task", @@ -1616,7 +1616,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.Task", diff --git a/packages/google-maps-fleetengine-delivery/tests/unit/gapic/fleetengine_delivery_v1/test_delivery_service.py b/packages/google-maps-fleetengine-delivery/tests/unit/gapic/fleetengine_delivery_v1/test_delivery_service.py index 3baeecd86382..fbd1f540bdbf 100644 --- a/packages/google-maps-fleetengine-delivery/tests/unit/gapic/fleetengine_delivery_v1/test_delivery_service.py +++ b/packages/google-maps-fleetengine-delivery/tests/unit/gapic/fleetengine_delivery_v1/test_delivery_service.py @@ -4441,6 +4441,7 @@ def test_create_delivery_vehicle_rest_required_fields( response_value._content = json_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_delivery_vehicle(request) @@ -4508,6 +4509,7 @@ def test_create_delivery_vehicle_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_delivery_vehicle(**mock_args) @@ -4646,6 +4648,7 @@ def test_get_delivery_vehicle_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_delivery_vehicle(request) @@ -4691,6 +4694,7 @@ def test_get_delivery_vehicle_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_delivery_vehicle(**mock_args) @@ -4829,6 +4833,7 @@ def test_update_delivery_vehicle_rest_required_fields( response_value._content = json_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_delivery_vehicle(request) @@ -4890,6 +4895,7 @@ def test_update_delivery_vehicle_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_delivery_vehicle(**mock_args) @@ -5027,6 +5033,7 @@ def test_batch_create_tasks_rest_required_fields( response_value._content = json_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_tasks(request) @@ -5167,6 +5174,7 @@ def test_create_task_rest_required_fields(request_type=delivery_api.CreateTaskRe response_value._content = json_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) @@ -5234,6 +5242,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) @@ -5365,6 +5374,7 @@ def test_get_task_rest_required_fields(request_type=delivery_api.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) @@ -5410,6 +5420,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) @@ -5540,6 +5551,7 @@ def test_update_task_rest_required_fields(request_type=delivery_api.UpdateTaskRe response_value._content = json_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_task(request) @@ -5599,6 +5611,7 @@ def test_update_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.update_task(**mock_args) @@ -5736,6 +5749,7 @@ def test_list_tasks_rest_required_fields(request_type=delivery_api.ListTasksRequ response_value._content = json_return_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) @@ -5791,6 +5805,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) @@ -5988,6 +6003,7 @@ def test_get_task_tracking_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_task_tracking_info(request) @@ -6033,6 +6049,7 @@ def test_get_task_tracking_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_task_tracking_info(**mock_args) @@ -6178,6 +6195,7 @@ def test_list_delivery_vehicles_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_delivery_vehicles(request) @@ -6234,6 +6252,7 @@ def test_list_delivery_vehicles_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_delivery_vehicles(**mock_args) @@ -7633,6 +7652,7 @@ def test_create_delivery_vehicle_rest_bad_request( response_value.status_code = 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_delivery_vehicle(request) @@ -7806,6 +7826,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_delivery_vehicle(request) # Establish that the response is the type that we expect. @@ -7851,6 +7872,7 @@ def test_create_delivery_vehicle_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = delivery_vehicles.DeliveryVehicle.to_json( delivery_vehicles.DeliveryVehicle() ) @@ -7897,6 +7919,7 @@ def test_get_delivery_vehicle_rest_bad_request( response_value.status_code = 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_delivery_vehicle(request) @@ -7935,6 +7958,7 @@ def test_get_delivery_vehicle_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_delivery_vehicle(request) # Establish that the response is the type that we expect. @@ -7980,6 +8004,7 @@ def test_get_delivery_vehicle_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = delivery_vehicles.DeliveryVehicle.to_json( delivery_vehicles.DeliveryVehicle() ) @@ -8028,6 +8053,7 @@ def test_update_delivery_vehicle_rest_bad_request( response_value.status_code = 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_delivery_vehicle(request) @@ -8203,6 +8229,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_delivery_vehicle(request) # Establish that the response is the type that we expect. @@ -8248,6 +8275,7 @@ def test_update_delivery_vehicle_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = delivery_vehicles.DeliveryVehicle.to_json( delivery_vehicles.DeliveryVehicle() ) @@ -8294,6 +8322,7 @@ def test_batch_create_tasks_rest_bad_request( response_value.status_code = 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_tasks(request) @@ -8327,6 +8356,7 @@ def test_batch_create_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.batch_create_tasks(request) # Establish that the response is the type that we expect. @@ -8366,6 +8396,7 @@ def test_batch_create_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 = delivery_api.BatchCreateTasksResponse.to_json( delivery_api.BatchCreateTasksResponse() ) @@ -8410,6 +8441,7 @@ def test_create_task_rest_bad_request(request_type=delivery_api.CreateTaskReques response_value.status_code = 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) @@ -8605,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.create_task(request) # Establish that the response is the type that we expect. @@ -8652,6 +8685,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 = tasks.Task.to_json(tasks.Task()) req.return_value.content = return_value @@ -8694,6 +8728,7 @@ def test_get_task_rest_bad_request(request_type=delivery_api.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) @@ -8735,6 +8770,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. @@ -8782,6 +8818,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 = tasks.Task.to_json(tasks.Task()) req.return_value.content = return_value @@ -8824,6 +8861,7 @@ def test_update_task_rest_bad_request(request_type=delivery_api.UpdateTaskReques response_value.status_code = 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_task(request) @@ -9019,6 +9057,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_task(request) # Establish that the response is the type that we expect. @@ -9066,6 +9105,7 @@ def test_update_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 = tasks.Task.to_json(tasks.Task()) req.return_value.content = return_value @@ -9108,6 +9148,7 @@ def test_list_tasks_rest_bad_request(request_type=delivery_api.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) @@ -9144,6 +9185,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. @@ -9183,6 +9225,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 = delivery_api.ListTasksResponse.to_json( delivery_api.ListTasksResponse() ) @@ -9229,6 +9272,7 @@ def test_get_task_tracking_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_task_tracking_info(request) @@ -9267,6 +9311,7 @@ def test_get_task_tracking_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_task_tracking_info(request) # Establish that the response is the type that we expect. @@ -9310,6 +9355,7 @@ def test_get_task_tracking_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 = task_tracking_info.TaskTrackingInfo.to_json( task_tracking_info.TaskTrackingInfo() ) @@ -9356,6 +9402,7 @@ def test_list_delivery_vehicles_rest_bad_request( response_value.status_code = 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_delivery_vehicles(request) @@ -9392,6 +9439,7 @@ def test_list_delivery_vehicles_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_delivery_vehicles(request) # Establish that the response is the type that we expect. @@ -9433,6 +9481,7 @@ def test_list_delivery_vehicles_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = delivery_api.ListDeliveryVehiclesResponse.to_json( delivery_api.ListDeliveryVehiclesResponse() ) diff --git a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/async_client.py b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/async_client.py index 901f8da01f11..abea31f9f429 100644 --- a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/async_client.py +++ b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_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, TripServiceTransport from .transports.grpc_asyncio import TripServiceGrpcAsyncIOTransport +try: + from google.api_core import client_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 TripServiceAsyncClient: """Trip management service.""" @@ -255,13 +265,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `maps.fleetengine_v1.TripServiceAsyncClient`.", + extra={ + "serviceName": "maps.fleetengine.v1.TripService", + "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": "maps.fleetengine.v1.TripService", + "credentialsType": None, + }, + ) + async def create_trip( self, request: Optional[Union[trip_api.CreateTripRequest, 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]]] = (), ) -> trips.Trip: r"""Creates a trip in the Fleet Engine and returns the new trip. @@ -299,8 +331,10 @@ async def sample_create_trip(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_v1.types.Trip: @@ -350,7 +384,7 @@ async def get_trip( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> trips.Trip: r"""Get information about a single trip. @@ -386,8 +420,10 @@ async def sample_get_trip(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_v1.types.Trip: @@ -435,7 +471,7 @@ async def report_billable_trip( *, retry: OptionalRetry = 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"""Report billable trip usage. @@ -469,8 +505,10 @@ async def sample_report_billable_trip(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -513,7 +551,7 @@ async def search_trips( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchTripsAsyncPager: r"""Get all the trips for a specific vehicle. @@ -550,8 +588,10 @@ async def sample_search_trips(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_v1.services.trip_service.pagers.SearchTripsAsyncPager: @@ -617,7 +657,7 @@ async def update_trip( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> trips.Trip: r"""Updates trip data. @@ -653,8 +693,10 @@ async def sample_update_trip(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_v1.types.Trip: diff --git a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/client.py b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/client.py index e9c38cbe63e7..dc6dd2dca463 100644 --- a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/client.py +++ b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_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 duration_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore from google.protobuf import wrappers_pb2 # type: ignore @@ -574,6 +584,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,13 +650,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 `maps.fleetengine_v1.TripServiceClient`.", + extra={ + "serviceName": "maps.fleetengine.v1.TripService", + "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": "maps.fleetengine.v1.TripService", + "credentialsType": None, + }, + ) + def create_trip( self, request: Optional[Union[trip_api.CreateTripRequest, 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]]] = (), ) -> trips.Trip: r"""Creates a trip in the Fleet Engine and returns the new trip. @@ -680,8 +717,10 @@ def sample_create_trip(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_v1.types.Trip: @@ -729,7 +768,7 @@ def get_trip( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> trips.Trip: r"""Get information about a single trip. @@ -765,8 +804,10 @@ def sample_get_trip(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_v1.types.Trip: @@ -814,7 +855,7 @@ def report_billable_trip( *, retry: OptionalRetry = 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"""Report billable trip usage. @@ -848,8 +889,10 @@ def sample_report_billable_trip(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -890,7 +933,7 @@ def search_trips( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchTripsPager: r"""Get all the trips for a specific vehicle. @@ -927,8 +970,10 @@ def sample_search_trips(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_v1.services.trip_service.pagers.SearchTripsPager: @@ -992,7 +1037,7 @@ def update_trip( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> trips.Trip: r"""Updates trip data. @@ -1028,8 +1073,10 @@ def sample_update_trip(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_v1.types.Trip: diff --git a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/pagers.py b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/pagers.py index c77ea169c4df..25bf421ab890 100644 --- a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/pagers.py +++ b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_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 = trip_api.SearchTripsRequest(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 = trip_api.SearchTripsRequest(request) diff --git a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/transports/grpc.py b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/transports/grpc.py index 94c71d1babb7..cd4b61872019 100644 --- a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/transports/grpc.py +++ b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_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.maps.fleetengine_v1.types import trip_api, trips from .base import DEFAULT_CLIENT_INFO, TripServiceTransport +try: + from google.api_core import client_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": "maps.fleetengine.v1.TripService", + "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": "maps.fleetengine.v1.TripService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TripServiceGrpcTransport(TripServiceTransport): """gRPC backend transport for TripService. @@ -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 @@ -253,7 +339,7 @@ def create_trip(self) -> Callable[[trip_api.CreateTripRequest], trips.Trip]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_trip" not in self._stubs: - self._stubs["create_trip"] = self.grpc_channel.unary_unary( + self._stubs["create_trip"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.TripService/CreateTrip", request_serializer=trip_api.CreateTripRequest.serialize, response_deserializer=trips.Trip.deserialize, @@ -277,7 +363,7 @@ def get_trip(self) -> Callable[[trip_api.GetTripRequest], trips.Trip]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_trip" not in self._stubs: - self._stubs["get_trip"] = self.grpc_channel.unary_unary( + self._stubs["get_trip"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.TripService/GetTrip", request_serializer=trip_api.GetTripRequest.serialize, response_deserializer=trips.Trip.deserialize, @@ -303,7 +389,7 @@ def report_billable_trip( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "report_billable_trip" not in self._stubs: - self._stubs["report_billable_trip"] = self.grpc_channel.unary_unary( + self._stubs["report_billable_trip"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.TripService/ReportBillableTrip", request_serializer=trip_api.ReportBillableTripRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -329,7 +415,7 @@ def search_trips( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_trips" not in self._stubs: - self._stubs["search_trips"] = self.grpc_channel.unary_unary( + self._stubs["search_trips"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.TripService/SearchTrips", request_serializer=trip_api.SearchTripsRequest.serialize, response_deserializer=trip_api.SearchTripsResponse.deserialize, @@ -353,7 +439,7 @@ def update_trip(self) -> Callable[[trip_api.UpdateTripRequest], trips.Trip]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_trip" not in self._stubs: - self._stubs["update_trip"] = self.grpc_channel.unary_unary( + self._stubs["update_trip"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.TripService/UpdateTrip", request_serializer=trip_api.UpdateTripRequest.serialize, response_deserializer=trips.Trip.deserialize, @@ -361,7 +447,7 @@ def update_trip(self) -> Callable[[trip_api.UpdateTripRequest], trips.Trip]: return self._stubs["update_trip"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/transports/grpc_asyncio.py b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/transports/grpc_asyncio.py index 5be75436974d..e8ee4571fe01 100644 --- a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/transports/grpc_asyncio.py +++ b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_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.maps.fleetengine_v1.types import trip_api, trips from .base import DEFAULT_CLIENT_INFO, TripServiceTransport from .grpc import TripServiceGrpcTransport +try: + from google.api_core import client_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": "maps.fleetengine.v1.TripService", + "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": "maps.fleetengine.v1.TripService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TripServiceGrpcAsyncIOTransport(TripServiceTransport): """gRPC AsyncIO backend transport for TripService. @@ -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 @@ -263,7 +348,7 @@ def create_trip( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_trip" not in self._stubs: - self._stubs["create_trip"] = self.grpc_channel.unary_unary( + self._stubs["create_trip"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.TripService/CreateTrip", request_serializer=trip_api.CreateTripRequest.serialize, response_deserializer=trips.Trip.deserialize, @@ -287,7 +372,7 @@ def get_trip(self) -> Callable[[trip_api.GetTripRequest], Awaitable[trips.Trip]] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_trip" not in self._stubs: - self._stubs["get_trip"] = self.grpc_channel.unary_unary( + self._stubs["get_trip"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.TripService/GetTrip", request_serializer=trip_api.GetTripRequest.serialize, response_deserializer=trips.Trip.deserialize, @@ -313,7 +398,7 @@ def report_billable_trip( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "report_billable_trip" not in self._stubs: - self._stubs["report_billable_trip"] = self.grpc_channel.unary_unary( + self._stubs["report_billable_trip"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.TripService/ReportBillableTrip", request_serializer=trip_api.ReportBillableTripRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -341,7 +426,7 @@ def search_trips( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_trips" not in self._stubs: - self._stubs["search_trips"] = self.grpc_channel.unary_unary( + self._stubs["search_trips"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.TripService/SearchTrips", request_serializer=trip_api.SearchTripsRequest.serialize, response_deserializer=trip_api.SearchTripsResponse.deserialize, @@ -367,7 +452,7 @@ def update_trip( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_trip" not in self._stubs: - self._stubs["update_trip"] = self.grpc_channel.unary_unary( + self._stubs["update_trip"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.TripService/UpdateTrip", request_serializer=trip_api.UpdateTripRequest.serialize, response_deserializer=trips.Trip.deserialize, @@ -446,7 +531,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-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/async_client.py b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/async_client.py index 55f0e2fbbdb9..190de83c06ed 100644 --- a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/async_client.py +++ b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_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, @@ -52,6 +53,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, VehicleServiceTransport from .transports.grpc_asyncio import VehicleServiceGrpcAsyncIOTransport +try: + from google.api_core import client_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 VehicleServiceAsyncClient: """Vehicle management service.""" @@ -257,13 +267,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `maps.fleetengine_v1.VehicleServiceAsyncClient`.", + extra={ + "serviceName": "maps.fleetengine.v1.VehicleService", + "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": "maps.fleetengine.v1.VehicleService", + "credentialsType": None, + }, + ) + async def create_vehicle( self, request: Optional[Union[vehicle_api.CreateVehicleRequest, 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]]] = (), ) -> vehicles.Vehicle: r"""Instantiates a new vehicle associated with an on-demand rideshare or deliveries provider. Each ``Vehicle`` must have a @@ -330,8 +362,10 @@ async def sample_create_vehicle(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_v1.types.Vehicle: @@ -381,7 +415,7 @@ async def get_vehicle( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vehicles.Vehicle: r"""Returns a vehicle from the Fleet Engine. @@ -417,8 +451,10 @@ async def sample_get_vehicle(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_v1.types.Vehicle: @@ -468,7 +504,7 @@ async def update_vehicle( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vehicles.Vehicle: r"""Writes updated vehicle data to the Fleet Engine. @@ -521,8 +557,10 @@ async def sample_update_vehicle(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_v1.types.Vehicle: @@ -574,7 +612,7 @@ async def update_vehicle_attributes( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vehicle_api.UpdateVehicleAttributesResponse: r"""Partially updates a vehicle's attributes. Only the attributes mentioned in the request will be updated, other attributes will @@ -619,8 +657,10 @@ async def sample_update_vehicle_attributes(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_v1.types.UpdateVehicleAttributesResponse: @@ -670,7 +710,7 @@ async def list_vehicles( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListVehiclesAsyncPager: r"""Returns a paginated list of vehicles associated with a provider that match the request options. @@ -709,8 +749,10 @@ async def sample_list_vehicles(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_v1.services.vehicle_service.pagers.ListVehiclesAsyncPager: @@ -775,7 +817,7 @@ async def search_vehicles( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vehicle_api.SearchVehiclesResponse: r"""Returns a list of vehicles that match the request options. @@ -817,8 +859,10 @@ async def sample_search_vehicles(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_v1.types.SearchVehiclesResponse: diff --git a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/client.py b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/client.py index b0237d56bda6..dafbdcee4a2f 100644 --- a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/client.py +++ b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_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.protobuf import wrappers_pb2 # type: ignore @@ -574,6 +584,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( @@ -639,13 +653,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 `maps.fleetengine_v1.VehicleServiceClient`.", + extra={ + "serviceName": "maps.fleetengine.v1.VehicleService", + "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": "maps.fleetengine.v1.VehicleService", + "credentialsType": None, + }, + ) + def create_vehicle( self, request: Optional[Union[vehicle_api.CreateVehicleRequest, 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]]] = (), ) -> vehicles.Vehicle: r"""Instantiates a new vehicle associated with an on-demand rideshare or deliveries provider. Each ``Vehicle`` must have a @@ -712,8 +749,10 @@ def sample_create_vehicle(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_v1.types.Vehicle: @@ -761,7 +800,7 @@ def get_vehicle( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vehicles.Vehicle: r"""Returns a vehicle from the Fleet Engine. @@ -797,8 +836,10 @@ def sample_get_vehicle(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_v1.types.Vehicle: @@ -846,7 +887,7 @@ def update_vehicle( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vehicles.Vehicle: r"""Writes updated vehicle data to the Fleet Engine. @@ -899,8 +940,10 @@ def sample_update_vehicle(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_v1.types.Vehicle: @@ -950,7 +993,7 @@ def update_vehicle_attributes( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vehicle_api.UpdateVehicleAttributesResponse: r"""Partially updates a vehicle's attributes. Only the attributes mentioned in the request will be updated, other attributes will @@ -995,8 +1038,10 @@ def sample_update_vehicle_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.maps.fleetengine_v1.types.UpdateVehicleAttributesResponse: @@ -1046,7 +1091,7 @@ def list_vehicles( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListVehiclesPager: r"""Returns a paginated list of vehicles associated with a provider that match the request options. @@ -1085,8 +1130,10 @@ def sample_list_vehicles(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_v1.services.vehicle_service.pagers.ListVehiclesPager: @@ -1149,7 +1196,7 @@ def search_vehicles( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vehicle_api.SearchVehiclesResponse: r"""Returns a list of vehicles that match the request options. @@ -1191,8 +1238,10 @@ def sample_search_vehicles(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.maps.fleetengine_v1.types.SearchVehiclesResponse: diff --git a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/pagers.py b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/pagers.py index f57049f143ec..4bee10cc5629 100644 --- a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/pagers.py +++ b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_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 = vehicle_api.ListVehiclesRequest(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 = vehicle_api.ListVehiclesRequest(request) diff --git a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/transports/grpc.py b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/transports/grpc.py index 4dd10753e65b..4969f1f69320 100644 --- a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/transports/grpc.py +++ b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_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.maps.fleetengine_v1.types import vehicle_api, vehicles from .base import DEFAULT_CLIENT_INFO, VehicleServiceTransport +try: + from google.api_core import client_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": "maps.fleetengine.v1.VehicleService", + "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": "maps.fleetengine.v1.VehicleService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VehicleServiceGrpcTransport(VehicleServiceTransport): """gRPC backend transport for VehicleService. @@ -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 @@ -283,7 +369,7 @@ def create_vehicle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_vehicle" not in self._stubs: - self._stubs["create_vehicle"] = self.grpc_channel.unary_unary( + self._stubs["create_vehicle"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.VehicleService/CreateVehicle", request_serializer=vehicle_api.CreateVehicleRequest.serialize, response_deserializer=vehicles.Vehicle.deserialize, @@ -309,7 +395,7 @@ def get_vehicle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_vehicle" not in self._stubs: - self._stubs["get_vehicle"] = self.grpc_channel.unary_unary( + self._stubs["get_vehicle"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.VehicleService/GetVehicle", request_serializer=vehicle_api.GetVehicleRequest.serialize, response_deserializer=vehicles.Vehicle.deserialize, @@ -352,7 +438,7 @@ def update_vehicle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_vehicle" not in self._stubs: - self._stubs["update_vehicle"] = self.grpc_channel.unary_unary( + self._stubs["update_vehicle"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.VehicleService/UpdateVehicle", request_serializer=vehicle_api.UpdateVehicleRequest.serialize, response_deserializer=vehicles.Vehicle.deserialize, @@ -386,7 +472,7 @@ def update_vehicle_attributes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_vehicle_attributes" not in self._stubs: - self._stubs["update_vehicle_attributes"] = self.grpc_channel.unary_unary( + self._stubs["update_vehicle_attributes"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.VehicleService/UpdateVehicleAttributes", request_serializer=vehicle_api.UpdateVehicleAttributesRequest.serialize, response_deserializer=vehicle_api.UpdateVehicleAttributesResponse.deserialize, @@ -413,7 +499,7 @@ def list_vehicles( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_vehicles" not in self._stubs: - self._stubs["list_vehicles"] = self.grpc_channel.unary_unary( + self._stubs["list_vehicles"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.VehicleService/ListVehicles", request_serializer=vehicle_api.ListVehiclesRequest.serialize, response_deserializer=vehicle_api.ListVehiclesResponse.deserialize, @@ -442,7 +528,7 @@ def search_vehicles( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_vehicles" not in self._stubs: - self._stubs["search_vehicles"] = self.grpc_channel.unary_unary( + self._stubs["search_vehicles"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.VehicleService/SearchVehicles", request_serializer=vehicle_api.SearchVehiclesRequest.serialize, response_deserializer=vehicle_api.SearchVehiclesResponse.deserialize, @@ -450,7 +536,7 @@ def search_vehicles( return self._stubs["search_vehicles"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/transports/grpc_asyncio.py b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/transports/grpc_asyncio.py index e22c75be1254..a0ef9113b619 100644 --- a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/transports/grpc_asyncio.py +++ b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_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.maps.fleetengine_v1.types import vehicle_api, vehicles from .base import DEFAULT_CLIENT_INFO, VehicleServiceTransport from .grpc import VehicleServiceGrpcTransport +try: + from google.api_core import client_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": "maps.fleetengine.v1.VehicleService", + "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": "maps.fleetengine.v1.VehicleService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VehicleServiceGrpcAsyncIOTransport(VehicleServiceTransport): """gRPC AsyncIO backend transport for VehicleService. @@ -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 @@ -291,7 +376,7 @@ def create_vehicle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_vehicle" not in self._stubs: - self._stubs["create_vehicle"] = self.grpc_channel.unary_unary( + self._stubs["create_vehicle"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.VehicleService/CreateVehicle", request_serializer=vehicle_api.CreateVehicleRequest.serialize, response_deserializer=vehicles.Vehicle.deserialize, @@ -317,7 +402,7 @@ def get_vehicle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_vehicle" not in self._stubs: - self._stubs["get_vehicle"] = self.grpc_channel.unary_unary( + self._stubs["get_vehicle"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.VehicleService/GetVehicle", request_serializer=vehicle_api.GetVehicleRequest.serialize, response_deserializer=vehicles.Vehicle.deserialize, @@ -360,7 +445,7 @@ def update_vehicle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_vehicle" not in self._stubs: - self._stubs["update_vehicle"] = self.grpc_channel.unary_unary( + self._stubs["update_vehicle"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.VehicleService/UpdateVehicle", request_serializer=vehicle_api.UpdateVehicleRequest.serialize, response_deserializer=vehicles.Vehicle.deserialize, @@ -394,7 +479,7 @@ def update_vehicle_attributes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_vehicle_attributes" not in self._stubs: - self._stubs["update_vehicle_attributes"] = self.grpc_channel.unary_unary( + self._stubs["update_vehicle_attributes"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.VehicleService/UpdateVehicleAttributes", request_serializer=vehicle_api.UpdateVehicleAttributesRequest.serialize, response_deserializer=vehicle_api.UpdateVehicleAttributesResponse.deserialize, @@ -423,7 +508,7 @@ def list_vehicles( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_vehicles" not in self._stubs: - self._stubs["list_vehicles"] = self.grpc_channel.unary_unary( + self._stubs["list_vehicles"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.VehicleService/ListVehicles", request_serializer=vehicle_api.ListVehiclesRequest.serialize, response_deserializer=vehicle_api.ListVehiclesResponse.deserialize, @@ -453,7 +538,7 @@ def search_vehicles( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_vehicles" not in self._stubs: - self._stubs["search_vehicles"] = self.grpc_channel.unary_unary( + self._stubs["search_vehicles"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.VehicleService/SearchVehicles", request_serializer=vehicle_api.SearchVehiclesRequest.serialize, response_deserializer=vehicle_api.SearchVehiclesResponse.deserialize, @@ -546,7 +631,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-maps-fleetengine/samples/generated_samples/snippet_metadata_maps.fleetengine.v1.json b/packages/google-maps-fleetengine/samples/generated_samples/snippet_metadata_maps.fleetengine.v1.json index b0139d358773..6ab744378c79 100644 --- a/packages/google-maps-fleetengine/samples/generated_samples/snippet_metadata_maps.fleetengine.v1.json +++ b/packages/google-maps-fleetengine/samples/generated_samples/snippet_metadata_maps.fleetengine.v1.json @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.Trip", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.Trip", @@ -196,7 +196,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.Trip", @@ -272,7 +272,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.Trip", @@ -349,7 +349,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "report_billable_trip" @@ -422,7 +422,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "report_billable_trip" @@ -496,7 +496,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.services.trip_service.pagers.SearchTripsAsyncPager", @@ -572,7 +572,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.services.trip_service.pagers.SearchTripsPager", @@ -649,7 +649,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.Trip", @@ -725,7 +725,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.Trip", @@ -802,7 +802,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.Vehicle", @@ -878,7 +878,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.Vehicle", @@ -955,7 +955,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.Vehicle", @@ -1031,7 +1031,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.Vehicle", @@ -1108,7 +1108,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.services.vehicle_service.pagers.ListVehiclesAsyncPager", @@ -1184,7 +1184,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.services.vehicle_service.pagers.ListVehiclesPager", @@ -1261,7 +1261,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.SearchVehiclesResponse", @@ -1337,7 +1337,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.SearchVehiclesResponse", @@ -1414,7 +1414,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.UpdateVehicleAttributesResponse", @@ -1490,7 +1490,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.UpdateVehicleAttributesResponse", @@ -1567,7 +1567,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.Vehicle", @@ -1643,7 +1643,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.Vehicle",